[Pcsclite-muscle] Portable way to detect when a smart card is inserted

Ignacio Casal ignacio.casal
Mon Sep 15 05:18:45 PDT 2014


Hey guys,

do you know what is the proper way to detect when a smart card is inserted?

in some places I've seen something like this:

rgReaderStates[0].szReader = &mszReaders[iList[iReader]];
rgReaderStates[0].dwCurrentState = SCARD_STATE_EMPTY;

rv = SCardGetStatusChange(hContext, INFINITE, rgReaderStates, 1);

while this worked for me on linux with pcsclite it does not seem to work
for me on windows, while doing this next does:
rgReaderStates[0].szReader = &mszReaders[iList[iReader]];
rgReaderStates[0].dwCurrentState = SCARD_STATE_UNAWARE;

rv = SCardGetStatusChange(hContext, INFINITE, rgReaderStates, 1);

if (rv == SCARD_S_SUCCESS) {
  rgReaderStates[0].dwCurrentState = rgReaderStates[0].dwEventState;
}

rv = SCardGetStatusChange(hContext, INFINITE, rgReaderStates, 1);

As you can see I need to do the call twice, first to get the current state
and second to actually block to wait for the smart card to be inserted. Is
this second way the recommended way also on pcsclite? If yes is the first
version shown here in this mail some kind of shortcut for the 2 way call?
Is there a better way to check when a smart card is inserted?

Thanks in advance.

-- 
Ignacio Casal Quinteiro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pcsclite-muscle/attachments/20140915/cebf5de4/attachment.html>



More information about the pcsclite-muscle mailing list