Closed lucassarcanjo closed 4 months ago
Thank you so much!
Hi Lucas,
I tried to run your fork with SPI and Python3 modifications but I still get this error:
python Read.py
/home/pi/.../test/MFRC522-python/MFRC522.py:133: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(self.NRSTPD, GPIO.OUT)
Traceback (most recent call last):
File "Read.py", line 41, in <module>
MIFAREReader = MFRC522.MFRC522()
File "/home/pi/.../test/MFRC522-python/MFRC522.py", line 135, in __init__
self.MFRC522_Init()
File "/home/pi/.../test/MFRC522-python/MFRC522.py", line 406, in MFRC522_Init
self.MFRC522_Reset();
File "/home/pi/.../test/MFRC522-python/MFRC522.py", line 138, in MFRC522_Reset
self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE)
File "/home/pi/.../test/MFRC522-python/MFRC522.py", line 141, in Write_MFRC522
spi.transfer(((addr<<1)&0x7E,val))
TypeError: function takes exactly 2 arguments (1 given)
Last version of SPI is installed and pins are connected correctly as documentation explains.
Do you have any idea of that issue? Thanks in advace Lucas.
Regards.
Do you have any idea of that issue? Thanks in advace Lucas.
Hi @rami85,
See the modifications that I did in MFRC522.py
. The last update of SPI-Py lib changed the number of arguments in some functions.
The old way (your code on line 141):
spi.transfer(((addr<<1)&0x7E,val))
The new way:
spi.transfer(self.dev_dictionary, ((addr<<1)&0x7E,val))
Take a look at Files Changed tab. With slightly changes in lines 131, 141 and 144 your code must run 😄
Thank you Lucas, I cloned the master brach instead your fork.
However, I found a couple issues:
on line 310 on MFRC522.py:
print("Size: ".format(ackData[0]))
As you see, you lost a 'b'. It should be:
print("Size: ".format(backData[0]))
On the other hand, when the Read.py reads tags, the script prints:
Card detected
Card read UID: %s,%s,%s,%s
Size:
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
So.. it seems there is another bug on Read.py script.
Regards.
So.. it seems there is another bug on Read.py script.
Hey @rami85, I found what the bug is.
The old python formatting is using: print "%s" % example
The new one should be: print("{}".format(example)
I will change those things and upload a new version.
Best regards,
Marvin
Converting to python3 is also part of #78 and #28.
Hi All. I an probably missing something here. Are we waiting for @mxgxw to approve the pull request?
I'd include some modifications to run the project on python 3 environment (minor changes). I also modified some functions of read/write SPI, that were changed by LThiery (author of spi library of this sensor library).