Skip to content

Commit

Permalink
Merge pull request #193 from ottk3/master
Browse files Browse the repository at this point in the history
RDM6300 V2: Add separated variables and an additional timeout
  • Loading branch information
MiczFlor authored Sep 11, 2018
2 parents cc6030d + bf2115c commit 6721824
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions scripts/Reader_RDM6300.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,27 @@

class Reader:
def __init__(self):
device = '/dev/ttyS0'
baudrate = 9600
ser_timeout = 0.1

GPIO.setmode(GPIO.BCM)
self.rfid_serial = serial.Serial('/dev/ttyS0', 9600)
self.rfid_serial = serial.Serial(device, baudrate, timeout=ser_timeout)

def readCard(self):
while True:
card_id = ''
read_byte = self.rfid_serial.read()
if read_byte == b'\x02':
while read_byte != b'\x03':
read_byte = self.rfid_serial.read()
card_id += read_byte.decode('utf-8')
card_id = ''.join(x for x in card_id if x in string.printable)
return card_id
try:
read_byte = self.rfid_serial.read()
if read_byte == b'\x02':
while read_byte != b'\x03':
read_byte = self.rfid_serial.read()
card_id += read_byte.decode('utf-8')
card_id = ''.join(x for x in card_id if x in string.printable)
card_id
return card_id

except ValueError as e:
print(e)
self.readCard()

0 comments on commit 6721824

Please sign in to comment.