1

I'm trying to read data from an RFID (RMD6300) to Raspberry Pi 1 in python but after reading for 30-40 secs whitout interruptions it crashes with the following error message:

Traceback (most recent call last): File "tmp.py", line 7, in string = ser.read(20) File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 501, in read 'device reports readiness to read but returned no data ' serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

this is my code:

import serial
ser = serial.Serial('/dev/ttyAMA0',9600, timeout=1)
IDs = ["xxxxxxxxxx","xxxxxxxxxx"]
while True:
 bool = False;
 string = ser.read(20)
 if len(string) == 0:
 print "Insert tag"
 continue
 else:
 for i in range(len(IDs)):
 for l in range(len(string)):
 if IDs[i] in string:
 print IDs[i]
 bool = True
 break
 else:
 string = string[1:]+string[0]
 if bool:
 break
 if not bool:
 print "Not found"
asked Apr 20, 2017 at 14:04

1 Answer 1

3

Question: ... device reports readiness to read but returned no data

Increase your timeout:

ser = serial.Serial('/dev/ttyAMA0',9600, timeout=1)

Use try ... except

try:
 string = ser.read(20)
except serial.serialutil.SerialException:
 except_counter +=1
 if except_counter == 5:
 break
 time.sleep(1)

Question: ...device disconnected or multiple access on port?

Can you exclude this two points?

answered Apr 20, 2017 at 15:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.