Closed lwalter86 closed 8 years ago
NXP Explore-NFC reader doesn't use the Raspberry Pi pins we use to manage leds or buttons
A (quite dirty) workaround might be to run python script inside a Bash loop
until python cli_rpi_access.py; do
echo Script failed, retrying in 2 seconds...
sleep 2
done
http://serverfault.com/questions/80862/bash-script-repeat-command-if-it-returns-an-error
An other approach to consider might be to update WiringPi http://wiringpi.com/download-and-install/ and its Python wrapper https://github.com/WiringPi/WiringPi-Python
After updating WiringPi you should try
gpio -v
gpio readall
Reference: http://wiringpi.com/download-and-install/
Updating WiringPi Python wrapper may also be necessary
I did it. It works fine.
Le 07/04/2016 18:21, scls19fr a écrit :
After updating WiringPi you should try
|gpio -v gpio readall |
Reference: http://wiringpi.com/download-and-install/
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/RaspberryPi-Samples/py-my-key/issues/19#issuecomment-206978521
I think i fund the error.
The nxppy.Mifare()
function must be called once.
See the _read
function of the NxppyReader
class defined in readers module.
I would like to execute at init but i don't know how
Great news!
One way to fix it could be to create an (empty) initialize
method in BaseReader
and to implement this initialize
method in NxppyReader
class BaseReader(Base):
def initialize(self):
pass
class NxppyReader(BaseReader):
def initialize(self):
self.mifare = nxppy.Mifare()
def _read(self):
data = ''
try:
data = self.mifare.select()
except nxppy.SelectError:
pass
if data != '':
return data
else:
return None
We will need to explicitly call this initialize
method in cli_rpi_access.py
def create_reader(self):
reader = self.Reader(comment='First reader')
reader.initialize()
An other way could be to put nxppy.Mifare()
in __init__
but also call inherited class __init__
method using super(...)
.
I'm not sure about this second idea as Base
is an SQLAlchemy object class... and there is probably some magical stuff around this ;-) so it should be heavily "tested" using some print calls.
The initialise
method fix this issue but not in the create_reader()
function.
I fix it by calling the method in the main function for now.
I will consider this next week.
create_reader()
is only executed at init :
sudo python py_my_key/cli_rpi_access.py --init
Or, we need to execute nxppy.Mifare()
each time we start the application. So we have to put the initialize()
call in the run()
method of the app.
Yes you are right !
Thanks
You can probably now merge Led_management
branch with master
branch.
An error occurs a few minutes after we launch the script :