MFRC522-python icon indicating copy to clipboard operation
MFRC522-python copied to clipboard

facing thise error when am trying to run the Read.py

Open sandeeppusthey opened this issue 6 years ago • 44 comments

below is the stack trace for the error am facing when am trying to run the Read.py script..

Traceback (most recent call last): File "Read.py", line 41, in MIFAREReader = MFRC522.MFRC522() File "/home/pi/MFRC522-python/MFRC522.py", line 135, in init self.MFRC522_Init() File "/home/pi/MFRC522-python/MFRC522.py", line 406, in MFRC522_Init self.MFRC522_Reset(); File "/home/pi/MFRC522-python/MFRC522.py", line 138, in MFRC522_Reset self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE) File "/home/pi/MFRC522-python/MFRC522.py", line 141, in Write_MFRC522 spi.transfer(((addr<<1)&0x7E,val)) TypeError: function takes exactly 2 arguments (1 given)

sandeeppusthey avatar Feb 21 '19 05:02 sandeeppusthey

I'm facing same issue with python 2.713

hawaii-do avatar Feb 21 '19 09:02 hawaii-do

Hi, Have you tried with 3.5!

sandeeppusthey avatar Feb 21 '19 09:02 sandeeppusthey

Yes, it's seems that it's not compatible with python3 as it require parenthesis for printcommand.

hawaii-do avatar Feb 21 '19 09:02 hawaii-do

you can add parenthesis for all prints and try run.. i just tried on 2.7 as well same error for me.. am stuck here at this part

sandeeppusthey avatar Feb 21 '19 10:02 sandeeppusthey

i hope it is not hardware problem. coz mine is new

sandeeppusthey avatar Feb 21 '19 10:02 sandeeppusthey

The hardware is working. I have the problem after reinstalling raspbian.

hawaii-do avatar Feb 21 '19 10:02 hawaii-do

@te-ti oh you were able to run it previously?

sandeeppusthey avatar Feb 21 '19 10:02 sandeeppusthey

I've figure out the problem I guess. I think it come from https://github.com/lthiery/SPI-Py library.

hawaii-do avatar Feb 21 '19 11:02 hawaii-do

did you find anything? please share thanks if is working for you

sandeeppusthey avatar Feb 21 '19 11:02 sandeeppusthey

this is the snapshot of the locals when am trying to debug image

sandeeppusthey avatar Feb 21 '19 12:02 sandeeppusthey

same problem here it seems there are some problems with the recent updates from SPI-Py

Highlife93 avatar Feb 21 '19 14:02 Highlife93

If you "rollback" SPI-Py to commit before February 17th, it should work.

git clone https://github.com/lthiery/SPI-Py.git
git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68
sudo python setup.py install

hawaii-do avatar Feb 21 '19 14:02 hawaii-do

Error is fixed but my tag not detected..

sandeeppusthey avatar Feb 21 '19 15:02 sandeeppusthey

Same, I don't understand why.

hawaii-do avatar Feb 21 '19 16:02 hawaii-do

@te-ti emmm...I just want know have you fixed the problem? Change another one?Or fix the code? It's very important to me. Thank you very much!

DreamContribution avatar Feb 22 '19 05:02 DreamContribution

let me know if this works anyone.. thanks

sandeeppusthey avatar Feb 22 '19 08:02 sandeeppusthey

If you "rollback" SPI-Py to commit before February 17th, it should work.

git clone https://github.com/lthiery/SPI-Py.git
git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68
sudo python setup.py install

atlast working for me.. i have soldered the reader pins then it works..

sandeeppusthey avatar Feb 22 '19 09:02 sandeeppusthey

@sandeeppusthey Still not working for me... Can you post a picture of how you wire the pins from rfid reader to the pi board?

hawaii-do avatar Feb 22 '19 09:02 hawaii-do

img_2752

the pins must be tightly fixed into the board..

sandeeppusthey avatar Feb 22 '19 10:02 sandeeppusthey

Hi all, i stumbled on this as well on a RPI 3 B+ and Raspian Strech. First i changed GPIO 22 to 11, because of this comment "SPI_CLK on a RPi 3 is Pin number 23 = GPIO11 (not 22)" in https://www.raspberrypi.org/forums/viewtopic.php?t=147291 Then i got this error. Not much of a python pro, but figured it out by looking in the SPI test_script: https://github.com/lthiery/SPI-Py/blob/master/test_script.py The changed function spi.transfer wants the file descriptor from spi.openSPI. I saved it in a global var and added it where needed. So, by making these changes to MFRC522.py, it will run again with latest SPI. After downloading this file, rename to MFRC522.py, then overwrite your file in cloned git. With git diff MFRC522.py you can see the changes made.

I u are not on a RPi 3, change the line NRSTPD = 11 back to 22 :-)

MFRC522.py.txt

abrakhim avatar Feb 22 '19 22:02 abrakhim

@abrakhim Cool!It works!Oh ,mine is Raspberry 2B.So not the pin problem. wechatimg279 Thank you very much! @te-ti And I'm was not forget your advise!Without your's I cannot fix it so quickly!

DreamContribution avatar Feb 23 '19 00:02 DreamContribution

英语很差,用中文回答吧.因为新提交的SPI-Py中,spi.transfer需要两个参数,在MFRC522.py中定义device_0=spi.openSPI(device="/dev/spidev0.0", mode=0, speed=1000000),修改 spi.transfer( ((addr<<1)&0x7E,val))和val = spi.transfer((((addr<<1)&0x7E) | 0x80,0))为spi.transfer(self.device_0, ((addr<<1)&0x7E,val))和val = spi.transfer(self.device_0, (((addr<<1)&0x7E) | 0x80,0))即可.

feiyang3x avatar Mar 10 '19 13:03 feiyang3x

If you "rollback" SPI-Py to commit before February 17th, it should work.

git clone https://github.com/lthiery/SPI-Py.git
git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68
sudo python setup.py install

atlast working for me.. i have soldered the reader pins then it work

@te-ti i tried this : git clone https://github.com/lthiery/SPI-Py.git git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68 sudo python setup.py install

after git checkout .... i got this: fatal: Not a git repository (or any of the parent directories): .git what have i done wrong?

rubenoosterwijk avatar Mar 11 '19 14:03 rubenoosterwijk

If you "rollback" SPI-Py to commit before February 17th, it should work.

git clone https://github.com/lthiery/SPI-Py.git
git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68
sudo python setup.py install

atlast working for me.. i have soldered the reader pins then it work

@te-ti i tried this : git clone https://github.com/lthiery/SPI-Py.git git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68 sudo python setup.py install

after git checkout .... i got this: fatal: Not a git repository (or any of the parent directories): .git what have i done wrong?

Have you "cd" into the "SPI-Py" directory before running git checkout?

MatsCedergren avatar Mar 11 '19 20:03 MatsCedergren

just copy the MFRC522.py from the following project and it works. git clone https://github.com/pimylifeup/MFRC522-python.git

dbsfai avatar Mar 12 '19 03:03 dbsfai

@MatsCedergren Yes i did, still the same: pi@raspberrypi:~ $ git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68 fatal: Not a git repository (or any of the parent directories): .git

rubenoosterwijk avatar Mar 18 '19 09:03 rubenoosterwijk

me, I don't understand wh

it is the issue of [ spi.transfer() ],it need two arguments and the MFRC522.py file just one given!

pansjk avatar Mar 29 '19 23:03 pansjk

it need install python2?

JoinBelieve avatar May 10 '19 16:05 JoinBelieve

I can now detect card on Read.py. My problem was that I use python3 on Raspberry Pi3. I do some change:

  • after downloaded, sudo python3 setup.py install on /SPI-py (latest version)
  • Then i've changed all print in MFRC522.py like this print "test" -> print("test")
  • The NRSTPD is set to 11 in MFRC522.py

alexball80 avatar May 15 '19 12:05 alexball80

I've could resolve the issue after using older branch. First you clone it after that you enter into the recently created folder. and after that you execute this: git clone https://github.com/lthiery/SPI-Py.git git checkout -b 8cce26b9ee6e69eb041e9d5665944b88688fca68 sudo python setup.py install

this worked as a charm for me hopefully it helps others. Thank you.

diegohoyola avatar Sep 29 '19 20:09 diegohoyola