[Pcsclite-muscle] Unable to detect SCardGetStatusChange() after write
Allen Curtis
allen at criticalsoftwaresolutions.com
Tue Jun 6 20:57:20 PDT 2023
Hello,
I have an interesting problem. I have a program with 2 threads. One monitors SCardGetStatusChange() and performs actions with the tag taken on/off the reader. The other thread performs write operations to the tag on demand.
Both threads have their own context:
SCARDCONTEXT context = 0; ///< context for this thread
rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &context);
Create their own card connections in shared mode:
DWORD dwActiveProtocol = SCARD_PROTOCOL_UNSET;
LONG rv = SCardConnect(
context,
m_ntag->reader_name,
SCARD_SHARE_SHARED,
(SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1),
&handle,
&dwActiveProtocol);
Both threads release the card context immediately after accessing it.
SCardDisconnect(handle, SCARD_RESET_CARD); // SCARD_RESET_CARD);
SCardReleaseContext(context);
As long as the tag is not written to, SCardGetStatusChange() reliably detects the reader/card state changes. After the write, state changes are no longer detected.
bool is_tag_present = (m_ntag->reader_state.dwCurrentState & SCARD_STATE_PRESENT);
Any idea what the issue might be?
Thanks
More information about the pcsclite-muscle
mailing list