Closed lburg closed 7 years ago
I am not sure you can easily run a single test. To run the framework test suite use:
cd smartcard/test/framework
python testsuite_framework.py
I am not familiar with CardMonitor and CardMonitoringThread. Can you describe what you get now and what you want to get instead?
With the current implementation if I keep a RFID card close to the reader I only get notified once, i.e. notifyObservers
is called once, and so is the update(self, observable, actions)
function from my custom Observer
. What I'd like is for this function to be called several times as long as the reader sees the card.
The CardMonitoringThread
class keeps track of the list of cards it's already seen (the cards
attribute) and only notifies observers when the card read is not in this list. The newcardonly
argument I introduce disables this tracking when set to False
(defaults to True
), making CardMonitoringThread
always think the card is new and notify all observers.
Thanks for the help on running the tests, I'll get them working :)
Is the program also notified when the card is "removed"?
Nice catch, I juste fixed that behaviour!
Regarding the tests, whenever I try to run them I get an error :
» python testsuite_framework.py
regenerating local_config.py...
Traceback (most recent call last):
File "testsuite_framework.py", line 59, in <module>
configcheck.checklocalconfig()
File "../configcheck.py", line 62, in checklocalconfig
expectedATRs.append(getATR(reader))
File "../configcheck.py", line 38, in getATR
cc.connect()
File "/home/lburg/dev/pyscard/smartcard/CardConnectionDecorator.py", line 54, in connect
self.component.connect(protocol, mode, disposition)
File "/home/lburg/dev/pyscard/smartcard/pcsc/PCSCCardConnection.py", line 128, in connect
SCardGetErrorMessage(hresult))
smartcard.Exceptions.CardConnectionException: Unable to connect with protocol: T0 or T1. Card is unpowered.
The reader is powered on and the pcsc
service is running, do I need some kind of smartcard to be able to run tests?
Maybe you should debug your code and run the test suite using a normal (contact) reader.
Note that I will not accept your first patch with the newcardonly parameter. A card event should be notified once. Otherwise it is not an event.
Alright, I can understand that. We'll replicate this behaviour from our software then, I'm closing this PR :)
Thank you for your help!
Add a newcardonly argument to CardMonitor and CardMonitoringThread so that observers can get notified several times about the same card. Defaults to the current implementation of not notifying several times.
I need to check that a RFID reader keeps working under certain conditions (temperature, magnetic field, etc.), and it's not convenient (if not dangerous) to have a human perform these tasks. Thus the need for continuous notifications to detect if the reader stops working.
Is it something you can see go in the core of pyscard?
Also, I modified some tests but couldn't get them to run. How can I get them to run? I tried simply calling
python path/to/testcase_CardMonitor.py
but had errors when importinglocal_config
, then I had error importingconfigcheck
when trying to run the test suite. I also tried with thepython -m smartcard.test.testcase_CardMonitor
syntax but to no avail. I didn't find any doc around running tests either.Thanks!