santigimeno / node-pcsclite

Bindings over pcsclite to access Smart Cards
ISC License
170 stars 127 forks source link

Reader SCARD_SHARE_DIRECT connection error #49

Closed Klemen1337 closed 8 years ago

Klemen1337 commented 8 years ago

Hi, I am trying to connect to the reader with direct mode to write on LCD. It works on Linux, but not on Windows. Are the drivers different?

var LCD_CONTRAST = new Buffer([0xFF, 0x00, 0x6C, 0x00, 0x00]);

clearScreen: function (reader) {
    reader.connect({ share_mode: reader_object.SCARD_SHARE_DIRECT }, function (err, protocol) {
        reader.transmit(LCD_CLEAR, 40, reader.SCARD_PROTOCOL_RAW, function (err, data) {
            if (err) {
                console.log('error clearing screen:', err);
            }
        });
    });
}

I get [Error: SCardConnect error: Smart card was removed <0x8010069>] while trying to connect.

Cheers, K

santigimeno commented 8 years ago

@Klemen1337 I really don't know. What reader are you using? Does it have proprietary drivers? Do they distribute sample code to write on the LCD?

Klemen1337 commented 8 years ago

I am using ACR1222L reader with drivers from the official page. I can pickup state changes like the example code, but cant transmit direct commands. The same code works on Linux, but not Windows.

LudovicRousseau commented 8 years ago

The Windows CCID driver is far from perfect. The GNU/Linux one is much better :-)

Try again with a card inserted in the reader.

Klemen1337 commented 8 years ago

@LudovicRousseau yea I figured that out :stuck_out_tongue_winking_eye: It works if state is SCARD_STATE_PRESENT, but It is not how I want it to work.

LudovicRousseau commented 8 years ago

@Klemen1337 maybe ACS has a better driver.

Klemen1337 commented 8 years ago

@LudovicRousseau ACS drivers are the one I used...

santigimeno commented 8 years ago

@Klemen1337 aren't there code samples for the functionality you're testing in their drivers / documentation? If there are and they work maybe we can migrate it to use node-pcsclite.

LudovicRousseau commented 8 years ago

I do not use Windows so I am not sure of what I write. I would not be surprised if you can't connect to a reader with no card inserted, even with SCARD_SHARE_DIRECT. Your bug would then be a limitation PC/SC on Windows and not a bug in node-pcsclite.

santigimeno commented 8 years ago

I'm closing this. @Klemen1337 please reopen the issue if you think there's something actionable. Thanks