[Pcsclite-muscle] Windows PC/SC and SCARD_E_SERVICE_STOPPED

Ludovic Rousseau ludovic.rousseau at gmail.com
Wed Dec 29 09:45:49 PST 2021


Hello Michael,

Le mar. 28 déc. 2021 à 20:56, Michael StJohns <mstjohns at comcast.net> a écrit :
>
> Resent - first was rejected due to HTML??

Most probably.

> On 12/27/2021 12:06 PM, Ludovic Rousseau wrote:
> > Hello,
> >
> > Thanks to all for your answers.
> >
> > Le dim. 26 déc. 2021 à 20:09, Stephan Brunner
> > <s.brunner at stephan-brunner.net>  a écrit :
> >> Hi,
> >>
> >> A quick and dirty solution is to establish a new context when getting
> >> SCARD_E_SERVICE_STOPPED. I had this situation myself when dealing with
> >> this stuff. This method forces the service to start again and stay
> >> alive, until the next time the last reader disconnects...
> > Exact. This solves the problem.
> > Seehttps://ludovicrousseau.blogspot.com/2021/12/windows-pcsc-and-scardeservicestopped_27.html
> >
> > Now I have to implement a fix for PySCard.
> >
> > Bye
> >
> I think your fix is correct, but using SCardListReaders is non-optimal.
> Instead:
>
> On windows,
>
>  1. Establish a context using SCardEstablishContext
>  2. Use SCardGetStatusChange on an array of terminals of length 1, with
>     \\?PnP?\Notification as the sole terminal name.  Set all the values
>     to 0, and call this with a timeout of zero to fill in the array
>     properly.

I am well aware of the use of "\\?PnP?\Notification"
See my blog article "How to use SCardGetStatusChange()?"
https://ludovicrousseau.blogspot.com/2018/02/how-to-use-scardgetstatuschange.html

The problem is that macOS does NOT support "\\?PnP?\Notification"
See https://ludovicrousseau.blogspot.com/2015/12/os-x-el-capitan-missing-feature.html

So pyscard still has to loop around SCardListReaders(), at least on macOS.

Feel free to provide a patch for pyscard to use "\\?PnP?\Notification"
where it is supported :-)

Bye

-- 
 Dr. Ludovic Rousseau



More information about the pcsclite-muscle mailing list