Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sandeeppusthey opened this issue Feb 21, 2019 · 44 comments · Fixed by thejanky/MFRC522-python#1 · May be fixed by #73
Open

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

sandeeppusthey opened this issue Feb 21, 2019 · 44 comments · Fixed by thejanky/MFRC522-python#1 · May be fixed by #73

Comments

@sandeeppusthey
Copy link

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
Copy link

I'm facing same issue with python 2.713

@sandeeppusthey
Copy link
Author

Hi, Have you tried with 3.5!

@hawaii-do
Copy link

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

@sandeeppusthey
Copy link
Author

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
Copy link
Author

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

@hawaii-do
Copy link

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

@sandeeppusthey
Copy link
Author

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

@hawaii-do
Copy link

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

@sandeeppusthey
Copy link
Author

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

@sandeeppusthey
Copy link
Author

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

@Highlife93
Copy link

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

@hawaii-do
Copy link

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
Copy link
Author

Error is fixed but my tag not detected..

@hawaii-do
Copy link

Same, I don't understand why.

@DreamContribution
Copy link

@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
Copy link
Author

let me know if this works anyone.. thanks

@sandeeppusthey
Copy link
Author

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
Copy link

@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
Copy link
Author

img_2752

the pins must be tightly fixed into the board..

@abrakhim
Copy link

abrakhim commented Feb 22, 2019

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
Copy link

@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
Copy link

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

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
Copy link

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
Copy link

dbsfai commented Mar 12, 2019

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

@rubenoosterwijk
Copy link

@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
Copy link

pansjk commented Mar 29, 2019

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!

noamnelke added a commit to noamnelke/MFRC522-python that referenced this issue Apr 9, 2019
@noamnelke noamnelke linked a pull request Apr 9, 2019 that will close this issue
@JoinBelieve
Copy link

it need install python2?

@alexball80
Copy link

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

@diegohoyola
Copy link

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
Copy link

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
Copy link

alexball80 commented Oct 17, 2019

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
Copy link

daniellopez0708 commented Nov 14, 2019

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
Copy link

@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
Copy link

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

@KhinShoon
Copy link

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
Copy link

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
Copy link

@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
Copy link

"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
Copy link

@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
Copy link

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
Copy link

pansjk commented Feb 12, 2020 via email

@CharanYvvs
Copy link

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 .

kuihao added a commit to kuihao/MFRC522-python that referenced this issue Mar 12, 2022
Tehis patch update code to match Python3 version,
and fix the function api problem of new SPI-Py PKG in mxgxw#69
kuihao added a commit to kuihao/MFRC522-python that referenced this issue Mar 12, 2022
Tehis patch update code to match Python3 version,
and fix the function api problem of new SPI-Py PKG in mxgxw#69
kuihao added a commit to kuihao/MFRC522-python that referenced this issue Mar 12, 2022
This patch updates code to match Python3 version,
and fix the function api problem of new SPI-Py PKG in
mxgxw#69
@wmx-meow
Copy link

英语很差,用中文回答吧.因为新提交的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))
'''
简直在挖坟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet