-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to list readers #117
Comments
First test your smart card reader is visible under macOS. I guess that in your case NO reader was connected. Exact? |
Thanks for getting back to me. There is no problem with the reader. I think you missed my comment ,"Rolling back to pyscard 1.9.9 fixes the error for me." So if I uninstall the current version and install 1.9.9 the reader and code work fine. Seems to have broken after 2.x. |
Can you provide a complete sample code? And really run pcsctest when you get the "Service not available" error. |
Sample code file attached as TXT. I extracted it from a larger project but tested it to ensure the error happens. Sometimes I don't get the error but if I stop the script and restart it I will often get the error.
|
What is the result of pcsctest after you get the "Service not available." error? Did you removed the reader to get the error? |
The result of pcsctest is the same as before the error occurred. It shows command successful for all functions. I didn't remove the reader it has been plugged in all the time. Interestingly if I downgrade to version 1.9.9 the error goes away completely. For now as a workaround we have set the max version to 1.9.9 for mac users. |
I suspect the issue to be linked with db52d27 My problems:
|
Was able to reproduce on Big Sur using the below profile. macOS BigSur Testing SCardEstablishContext : Command successful. ➜ scanner python3 reader-test.py |
I can reproduce the error. |
Try with this patch: --- a/smartcard/pcsc/PCSCContext.py
+++ b/smartcard/pcsc/PCSCContext.py
@@ -52,7 +52,8 @@ class PCSCContext(object):
def __init__(self):
PCSCContext.mutex.acquire()
try:
- self.renewContext()
+ if not PCSCContext.instance:
+ self.renewContext()
finally:
PCSCContext.mutex.release() |
This reverts commit d5cf89c. This code introduced a regression on (at least) macOS, See LudovicRousseau/pyscard#117
@LudovicRousseau I applied the patch and rebuild using ➜ pyscard-master python3 setup.py build_ext install. Confirming the error is gone now. Thanks! |
Thanks for the feedback |
Your system information
Please describe your issue in as much detail as possible:
Describe what you expected should happen.
Return list of readers
Describe what did happen.
I get an error message and script fails to run.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/smartcard/CardMonitoring.py", line 163, in run
currentcards = self.cardrequest.waitforcardevent()
File "/usr/local/lib/python3.9/site-packages/smartcard/CardRequest.py", line 72, in waitforcardevent
return self.pcsccardrequest.waitforcardevent()
File "/usr/local/lib/python3.9/site-packages/smartcard/pcsc/PCSCCardRequest.py", line 291, in waitforcardevent
readernames = self.getReaderNames()
File "/usr/local/lib/python3.9/site-packages/smartcard/pcsc/PCSCCardRequest.py", line 93, in getReaderNames
raise ListReadersException(hresult)
smartcard.Exceptions.ListReadersException: Failed to list readers: Service not available. (0x-7FEFFFE3)
Steps for reproducing this issue:
The text was updated successfully, but these errors were encountered: