diff --git a/src/pcsc.c b/src/pcsc.c index 496918c..57ecc7f 100644 --- a/src/pcsc.c +++ b/src/pcsc.c @@ -610,14 +610,18 @@ int pcsc_wait_for_card(pcsc_ctx_t ctx, unsigned long timeout_ms, size_t* idx) struct pcsc_t* pcsc; LONG result; - if (!ctx) { + if (!ctx || !idx) { return -1; } pcsc = ctx; // Prepare reader states for card detection for (size_t i = 0; i < pcsc->reader_count; ++i) { - pcsc->reader_states[i].dwCurrentState = SCARD_STATE_EMPTY; + if (*idx == PCSC_READER_ANY || *idx == i) { + pcsc->reader_states[i].dwCurrentState = SCARD_STATE_EMPTY; + } else { + pcsc->reader_states[i].dwCurrentState = SCARD_STATE_IGNORE; + } } // Wait for empty state to change diff --git a/tools/emv-tool.c b/tools/emv-tool.c index f5856e5..06a676a 100644 --- a/tools/emv-tool.c +++ b/tools/emv-tool.c @@ -718,6 +718,7 @@ int main(int argc, char** argv) // Wait for card presentation printf("\nPresent card\n"); + reader_idx = PCSC_READER_ANY; r = pcsc_wait_for_card(pcsc, 5000, &reader_idx); if (r < 0) { printf("PC/SC error\n");