forked from anna/doors
Updates for key validation:
- Check the start and stop bytes of the RFID message in addition to the expected length to prevent crashes. - There is no need to re-lock the door if it was never unlocked. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
71db8b6220
commit
7296900ddf
4
doors.py
4
doors.py
|
@ -154,8 +154,8 @@ RFID_SERIAL = serial.Serial(RFID_PATH, 2400, timeout=1)
|
|||
def read_key():
|
||||
RFID_SERIAL.reset_input_buffer() # Clear input buffer before reading
|
||||
string = RFID_SERIAL.read(12)
|
||||
if len(string) > 0:
|
||||
key = string[1:11].decode() #exclude start x0A and stop x0D bytes
|
||||
if len(string) == 12 and string[0] == 0xA and string[-1] == 0xD:
|
||||
key = string[1:11].decode() #exclude start 0xA and stop 0xD bytes
|
||||
if key.isalnum():
|
||||
return key;
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue