I have a program in Java that successfully communicates with a Java Smart Card with a smart card reader using javax.smartcardio.*. With API monitor I have found out that the java.exe witch runs it is actually using WinSCard winAPI (It loads winscard.dll the moment I start communicating. I did not manage to find our the actual calls yet)
My problem is that I tried to implement the same thing in a Qt framework C++ program using the WinSCard library. Everything work well if I run the program in 10 seconds after the reader is plugged in the USB, but after that the reader goes into a state that I presume is some powers saving state, then a few seconds later it shots down the USB pipe. The java program automatically "wakes up" the reader when I try to connect to it, but the C++ I wrote does not, and I don't know what I'm doing wrong.
First I establish a context with SCardEstablishContext()
call, then I list readers with SCardListReaders()
, which actually list the reader is question, the finally I call SCardConnect()
to connect, with returns SCARD_E_NOT_READY
if the smart card reader is in this "sleep" state.
Please note that if the smart card reader is not is this "sleep" mode, I can communicate with the card with no problem with the same code.
The winAPI description gives no hint on what to do in this case, and I could not find any trace of what to do. If anyone knows a solution for this, please share!