[Pcsclite-muscle] Asynchronous PCSC API
Frank Morgner
frankmorgner at gmail.com
Wed Jan 26 04:25:58 PST 2022
Last time I tested, SCardCancel didn't abort *anything* on Windows; it
didn't even cancel the command for entering the PIN on the reader's
PIN pad. Back then, I've also tried stopping the calling process (and
invalidating the scardcontext), but still the PIN pad reader was
waiting for the PIN until the timeout was reached. As you can see,
this is not only a software limitation, but also a limitation in
hardware.
If you want something portable, use a shim layer around PC/SC to
achieve somewhat asynchronous calls. For example, you could implement
a queue, which at least allows aborting all waiting calls; however,
the PC/SC call that's currently execuded.
Note that asynchronous calls don't work well with the communication
model most smart cards are designed for. The smart card commands often
depend on a very specific order. Thus, a shim layer should allow
grouping incoming calls via SCardBeginTransaction/SCardEndTransaction.
Regards, Frank.
Am Mi., 26. Jan. 2022 um 10:55 Uhr schrieb Ievgenii Meshcheriakov
<ievgenii.meshcheriakov at qt.io>:
>
> вівторок, 25 січня 2022 р. 17:39:34 CET Ludovic Rousseau написано:
> > Good to know.
> > Maybe I should implement a similar behaviour in pcsc-lite.
> > You are the first one to request this feature.
> I really want to be able to make an asynchronous API for using PCSC. And
> SCardCancel is unfortunately the closest thing that is available.
>
> > How do you plan to use this new behaviour?
> > thread A: SCardConnect()
> > thread B: wait a bit
> > thread B: SCardCancel() to unblock SCardConnect() in thread A
> >
> > Then, what to do after that?
> > Try again to connect until it succeeds?
> > Something else?
> I didn't implement anything yet, but the idea is that there are worker threads
> that handle connections to cards. It's fine if SCardConnect is blocking there,
> but it should be possible to cancel the connection in case the user code wants
> to destroy the manager object or the application exits.
>
> > Would you prefer:
> > - a non blocking SCardConnect() using PCSCLITE_NO_BLOCKING?
> > - or a SCardConnect() you can cancel using SCardCancel()?
> The second one.
>
> Regards,
> Ievgenii
> _______________________________________________
> pcsclite-muscle mailing list
> pcsclite-muscle at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/pcsclite-muscle
More information about the pcsclite-muscle
mailing list