Closed vbnmmnbv closed 7 years ago
What OS and version are you using?
We have a customized OS. But it's based on Ubuntu 14 LTS.
The error "Service not available" indicates that pcscd is not (yet) running.
What version of pcsc-lite do you use?
Makes sense. Thanks. Next time when this happened, I will try to confirm.
pcsc-lite version 1.8.14. Copyright (C) 1999-2002 by David Corcoran corcoran@musclecard.com. Copyright (C) 2001-2011 by Ludovic Rousseau ludovic.rousseau@free.fr. Copyright (C) 2003-2004 by Damien Sauveron sauveron@labri.fr. Report bugs to muscle@lists.musclecard.com. Enabled features: Linux x86_64-pc-linux-gnu serial usb libudev usbdropdir=/usr/lib/pcsc/drivers ipcdir=/var/run/pcscd configdir=/etc/reader.conf.d
Do you have any clue why it is not running?
En... Thanks for your clue. I do find some "workaround" in our old code, trying to deal with not running of pcscd. Probably I should reuse that :) The code will try to restart pcscd and instantiate 'PCSCContext' if the System.readers() call fails.
Do you use systemd to start pcscd automatically? See https://ludovicrousseau.blogspot.fr/2011/11/pcscd-auto-start-using-systemd.html
It's not managed by systemd and no one will restart it if I killed it. I talked with the guy who added that workaround code before. He said the problem was not because the pcscd was not running. It's because it was not responding, which seems to be more reasonable as re-importing the smartcard module will solve the problem. So the workaround is to manually restart it. I will use that workaround for now.
Do you know why pcscd is not responding?
I have no idea. Maybe you can give me some guidance to debug. But I just reproduced it and let me describe the symptom.
I have a daemon which already imports smartcard.System.readers() and it works well most time. But when error happens, the readers() will raise exception as I mentioned before(stacktrace is in my first post). Trying to access the readers again through the daemon will cause the same issue.
However, the pcscd is not dead:
ps aux|grep pcs root 8299 0.0 0.0 331280 2960 ? Sl 14:54 0:00 /usr/sbin/pcscd root 9191 0.0 0.0 10708 2200 pts/10 S+ 15:16 0:00 grep --color=auto pcs
And if I open another ipython, import the module and call readers() there, there is no problem:
In [1]: from smartcard.System import readers
In [2]: readers() Out[2]: ['SCM Microsystems Inc. SCR 3310 [CCID Interface] 00 00']
I think the problem is already solved in a more recent version of pcsc-lite.
Problems with SCardCancel()
have been fixed in 1.4.16 and 1.4.21.
Please confirm upgrading pcsc-lite fixes your problem.
I do not quite understand. I am using 1.8.14 and you said the suspected problem has been fixed in 1.4.16. Then which version should I try to upgrade? 1.8.21?
Always use the latest version. Unless you have a very good reason not to upgrade.
Try again using the latest pcsc-lite. If the bug is still present then open an new issue.
Hi, I am using version 1.9.4 in python2. I will occasionally get this error. I have two smartcards attached. The problem will be solved if I re-import the module. Anyone has any clue or suggestion here? Thanks a lot~