[Pcsclite-muscle] How to dectect card status?

Carlos Almeida Jr. almeidajr at gmail.com
Fri Jun 26 18:24:06 EDT 2020


Hello!

I'm developing an application that needs to detect when a card is
removed from the reader.

I tried to use:

// fragment #1
m_readerState = new SCARD_READERSTATE[1];
m_readerState->szReader = m_readerModel;
SCardGetStatusChange(m_cardContext, 100000000, m_readerState, 1);
qDebug() << ">> Reader status" << m_readerState->dwCurrentState;

if(l_readerStatus == SCARD_STATE_PRESENT) {
   qDebug() << "card still present";
} else {
   qDebug() << "card not present";
}
// ---
// >> m_readerState->dwCurrentState always returns something like 94893093710928

or
// fragment #2
m_readerState = new SCARD_READERSTATE[1];
m_readerState->szReader = m_readerModel; // or "\\\\?PnP?\\Notification";
m_readerState->cbAtr = 0;
m_readerState->dwCurrentState = 0;
m_readerState->dwEventState = 0;
while(true) {
    SCardGetStatusChange(m_cardContext, 500, m_readerState, 1);
    qDebug() << ">> Reader status" << m_readerState->dwCurrentState <<
" --- " << SCARD_STATE_PRESENT;
}
// ---


// >> m_readerState->dwCurrentState always returns 0

m_cardContext and m_readerState are correctly defined and I'm able to
read cards but not to identify when it is disconnected.

Someone can help me?

Regards,
Carlos
Carlos Almeida Jr



More information about the pcsclite-muscle mailing list