1

I'm trying to make a ACR1222L work with this ruby script that I found on github. The script is made for the older ACR122U, but in my research I've seen that they both should be pretty similar.

My problem is when trying to run the script, I get this error:

C:\Users\Emil\Desktop>driver.rb
Calibration Time!

Place and leave a tag on the device
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/smartcard-0.5.5/lib/smartcard/pcsc/conte
xt.rb:112:in `wait_for_status_change':  (0x100000006) (Smartcard::PCSC::Exception)
        from C:/Users/Emil/Desktop/driver.rb:24:in `<main>'

Could it be that the "smartcard" gem used by the script does not support the ACR1222L, or am I simply just missing something?

Hope that someone can help!

EmilNygaard
  • 25
  • 1
  • 1
  • 5
  • 0x100000006 in `Smartcard::PCSC::Exception`-logic looks like an INVALID_HANDLE_EXCEPTION. What's the value of `queries[0].reader_name` before you execute `context.wait_for_status_change(queries)`on line 24? – Michael Roland May 15 '14 at 18:43
  • queries[0].reader_name is returns ACS ACR1222 3S PICC Reader PICC 0 – EmilNygaard May 15 '14 at 19:16
  • Then the only possible issue I see that could cause an INVALID_HANDLE_EXCEPTION is a 32-bit/64-bit mismatch. Could it be that the smartcard gem requires a 32-bit version of Ruby? Though I wonder why you can list the readers then... – Michael Roland May 15 '14 at 19:35
  • Very true! It needed a 32-bit version to work! Uninstalled 64 and installed 32, now it works! Thank you so much! Can you create an answer, so that I can upvote it? :) – EmilNygaard May 15 '14 at 20:42

1 Answers1

1

The Smartcard::PCSC::Exception error code you get (0x100000006) translates to the Windows API error code INVALID_HANDLE_EXCEPTION (0x00000006). This typically indicates that the context handle used in the API call is invalid. With the smartcard gem, the PS/SC context (SCardEstablishContext) is established through the initializer of Smartcard::PCSC::Context. This operation seems to be successful, otherwise you would get an exception on line 13. The source of the INVALID_HANDLE_EXCEPTION seems to be SCardGetStatusChange (invoked by context.wait_for_status_change).

A possible reason for that call to fail with an INVALID_HANDLE_EXCEPTION could be a mismatch in the handle format, for instance caused by a 32-bit/64-bit mismatch. Thus, I would assume that the smartcard gem is designed for 32-bit only (while your path indicates that you are using a 64-bit version of Ruby).

Michael Roland
  • 39,663
  • 10
  • 99
  • 206