From 5feac037c535dbd499a1bfbc344788cd26d23e07 Mon Sep 17 00:00:00 2001 From: Workantile Date: Thu, 9 Apr 2015 13:33:27 +0000 Subject: [PATCH] Changing to 'sidedoor' --- doorrc | 3 ++- doors.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doorrc b/doorrc index f79e8b0..3c11f2c 100644 --- a/doorrc +++ b/doorrc @@ -1,6 +1,7 @@ # Name of this Raspberry Pi unit -CONTROLLER="deadbeef01" +#CONTROLLER="deadbeef01" +CONTROLLER="sidedoor" # Server to send requests to SERVER = "http://openings.workantile.com/access/" + CONTROLLER diff --git a/doors.py b/doors.py index abf1f39..689a7a5 100644 --- a/doors.py +++ b/doors.py @@ -99,13 +99,20 @@ import serial RFID_SERIAL = serial.Serial(RFID_PATH, 2400, timeout=1) -while True: +def read_rfid(): string = RFID_SERIAL.read(12) if len(string) == 0: print("No tag read") - continue + #continue else: - key = string[1:11] #exclude start x0A and stop x0D bytes + key = string[1:11].decode() #exclude start x0A and stop x0D bytes print(key) verify_key(key) RFID_SERIAL.flushInput() # ignore errors, no data + + +while True: + try: + read_rfid() + except Exception(e): + print(e)