santigimeno / node-pcsclite

Bindings over pcsclite to access Smart Cards
ISC License
169 stars 124 forks source link

Card returning empty Buffer #54

Open Egnus opened 8 years ago

Egnus commented 8 years ago

Basically this is the example code i have used, other examples gives me the same result at the end.

`#!/usr/bin/env node
var pcsc = require('./lib/pcsclite');
var pcsc = pcsc();
pcsc.on('reader', function(reader) {

function exit() {
    reader.close();
    pcsc.close();
}

cmd_select = new Buffer([0x00, 0xA4, 0x04, 0x00, 0x0A, 0xA0, 0x00, 0x00, 0x00, 0x62, 0x03, 0x01, 0x0C, 0x06, 0x01]);
cmd_command = new Buffer([0x00, 0x00, 0x00, 0x00]);

console.log('Using:', reader.name);

reader.connect(function(err, protocol) {
    if (err) {
        console.log(err);
        return exit();
    }
    reader.transmit(cmd_select, 255, protocol, function(err, data) {
        if (err) {
            console.log(err);
            return exit();
        }
        console.log('Data received', data);
        reader.transmit(cmd_command, 255, protocol, function(err, data) {
            if (err) {
                console.log(err);
            } else {
                console.log('Data received', data);
                console.log('Data received', data.toString());

            }
            return exit();
        });
    });
});
});

pcsc.on('error', function(err) {
  console.log('PCSC error', err.message);
});`

But no matter which card i used it gives the same response (Mifare Ultralight and Mifare 1k classic)

Using: ACS ACR122 0 Data received < Buffer > Data received < Buffer > Data received

I have not idea what is going on with this. Im using Windows 10, everything seems to be builded successfully.

LudovicRousseau commented 8 years ago

Try to use SCardSpy to log the PC/SC commands and possible errors https://www.idrix.fr/Root/content/category/7/25/46/

jsmrcaga commented 8 years ago

I'm having an empty buffer retuned when trying to get a FAST_READ from a card. I'm using the command: [0xFF, 0x3A, 0x04, 0x0F] (read from page 4 to 15) from this ref (page 26).

Are there any known records of this?