mxgxw / MFRC522-python

A small class to interface with the NFC reader Module MFRC522
GNU Lesser General Public License v3.0
521 stars 419 forks source link

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

Open sandeeppusthey opened 5 years ago

sandeeppusthey commented 5 years ago

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)

hawaii-do commented 5 years ago

I'm facing same issue with python 2.713

sandeeppusthey commented 5 years ago

Hi, Have you tried with 3.5!

hawaii-do commented 5 years ago

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

sandeeppusthey commented 5 years ago

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 commented 5 years ago

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

hawaii-do commented 5 years ago

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

sandeeppusthey commented 5 years ago

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

hawaii-do commented 5 years ago

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

sandeeppusthey commented 5 years ago

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

sandeeppusthey commented 5 years ago

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

Highlife93 commented 5 years ago

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

hawaii-do commented 5 years ago

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
sandeeppusthey commented 5 years ago

Error is fixed but my tag not detected..

hawaii-do commented 5 years ago

Same, I don't understand why.

DreamContribution commented 5 years ago

@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!

sandeeppusthey commented 5 years ago

let me know if this works anyone.. thanks

sandeeppusthey commented 5 years ago

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..

hawaii-do commented 5 years ago

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

sandeeppusthey commented 5 years ago

img_2752

the pins must be tightly fixed into the board..

abrakhim commented 5 years ago

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

DreamContribution commented 5 years ago

@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!

feiyang3x commented 5 years ago

英语很差,用中文回答吧.因为新提交的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))即可.

rubenoosterwijk commented 5 years ago

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?

MatsCedergren commented 5 years ago

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?

dbsfai commented 5 years ago

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

rubenoosterwijk commented 5 years ago

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

pansjk commented 5 years ago

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!

JoinBelieve commented 5 years ago

it need install python2?

alexball80 commented 5 years ago

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

diegohoyola commented 4 years ago

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.

keitheyre commented 4 years ago

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

Error is fixed but my tag not detected..

Same with me. I have writing functionality but now the written card is not being read by the same device... Any ideas?

alexball80 commented 4 years ago

Hi, if this can help, in my notes of a working test (project of some months ago) i've noted this:

(Estrema attenzione alle saldature e ai contatti - problema per giorni!) <---- !!!!!!!!! Translated: (Extreme attention to welds and contacts - problem during many days!) !!!!!! Make attention to welding.

I have the NRSTPD = 22 and this is my pin config:

RC522 Pin   Pi GPIO pin PI GPIO signal and function
SDA      24     CS0 – This is the SPI chip select, active low
SCK      23     SCLK – this is the SPI clock
MOSI         19     MOSI – data to the RC522
MISO         21     MISO – data from the RC522
IRQ      –      -
GND      20     GND
RST      22     GPIO25
3.3V         17     3.3V
daniellopez0708 commented 4 years ago

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

Hey guys! So my issue is that the error is gone, but the tags are not detected... the pin config is identical to @alexball80 Any ideas?

alexball80 commented 4 years ago

@daniellopez0708 In my case one problem was welding contacts of shield (Extreme attention to welds and contacts - problem during many days ,Make attention to welding) Try with other RFID tags shields.

daniellopez0708 commented 4 years ago

@alexball80 I will re-weld the contacts and will let you now

KhinShoon commented 4 years ago

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

Thank you for this quote. this solution works for me on python3 but not with python2.7

KhinShoon commented 4 years ago

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

Hey guys! So my issue is that the error is gone, but the tags are not detected... the pin config is identical to @alexball80 Any ideas?

It was the same for me at first. make sure your tag is close to the reader range and try moving the reader position from the breadboard. Sometimes, pins are not detected in sync. That is my problem and it works now.

vshashankv3 commented 4 years ago

@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!

First disable the SPI and then enable the SPI and then tyr again. Worked for me

vshashankv3 commented 4 years ago

"sudo raspi-config" then go to interfacing option then go to p4 SPI disable that. then "sudo reboot" // to reboot the pi then again enable the spi interfacing by repeating above steps and reboot the system.

This thing worked for me..

daniellopez0708 commented 4 years ago

@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!

First disable the SPI and then enable the SPI and then tyr again. Worked for me

Hi! It is still not working for me but I will try what you said Did you use the @alexball80 pin config?

wahajmurtaza commented 4 years ago

Just found the solution that worked for me

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

After that Enable Remote-GPIO for raspberry pi interface.

worked with python3 and 2 on Pi 4

pansjk commented 4 years ago

thanks~~

------------------ 原始邮件 ------------------ 发件人: "MUHAMMAD WAHAJ MURTAZA"<notifications@github.com>; 发送时间: 2020年2月12日(星期三) 下午5:51 收件人: "mxgxw/MFRC522-python"<MFRC522-python@noreply.github.com>; 抄送: "951969769"<951969769@qq.com>; "Comment"<comment@noreply.github.com>; 主题: Re: [mxgxw/MFRC522-python] facing thise error when am trying to run the Read.py (#69)

Just found the solution that worked for me

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

After that Enable Remote-GPIO for raspberry pi interface.

worked with python3 and 2 on Pi 4

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

CharanYvvs commented 2 years ago

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

yes it worked for me. but when i place my rfid tag it is not detecting. can anyone help me out. its important for me as im using it for my major project .

wmx-meow commented 2 months ago

英语很差,用中文回答吧.因为新提交的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))即可.

非常感谢这位大哥 解决了 this reply works and solved my problem. a simple translation: define the following line in the class MFRC522 ''' device_0=spi.openSPI(device="/dev/spidev0.0", mode=0, speed=1000000) ''' then change these two lines: ''' spi.transfer( ((addr<<1)&0x7E,val)) val = spi.transfer((((addr<<1)&0x7E) | 0x80,0)) ''' into: ''' spi.transfer(self.device_0, ((addr<<1)&0x7E,val)) val = spi.transfer(self.device_0, (((addr<<1)&0x7E) | 0x80,0)) ''' 简直在挖坟