Make specific to RDM6300 card reader
This commit is contained in:
parent
60825fda94
commit
06cf642074
12
main.py
12
main.py
|
@ -51,7 +51,7 @@ def init():
|
|||
GPIO.output(RFID_EN_PIN, GPIO.LOW)
|
||||
logging.info('GPIO initialized')
|
||||
|
||||
ser = serial.Serial(port='/dev/ttyAMA0', baudrate=secrets.BAUD_RATE, timeout=0.1)
|
||||
ser = serial.Serial(port='/dev/ttyAMA0', baudrate=secrets.BAUD_RATE, timeout=0.05)
|
||||
logging.info('Serial initialized')
|
||||
|
||||
for sig in (SIGABRT, SIGILL, SIGINT, SIGSEGV, SIGTERM):
|
||||
|
@ -71,7 +71,8 @@ def reader_thread(card_data_queue):
|
|||
except Empty:
|
||||
pass
|
||||
|
||||
card = ser.readline()
|
||||
ser.reset_input_buffer()
|
||||
card = ser.read(100)
|
||||
|
||||
if not card:
|
||||
continue
|
||||
|
@ -83,16 +84,15 @@ def reader_thread(card_data_queue):
|
|||
except UnicodeDecodeError:
|
||||
continue
|
||||
|
||||
logging.debug('Card read string: %s', card)
|
||||
card = card[1:11]
|
||||
|
||||
if len(card) != 10:
|
||||
logging.debug('Card length not 10, skipping')
|
||||
continue
|
||||
logging.debug('Card read string: %s', card)
|
||||
|
||||
# debounce card scans
|
||||
now = time.time()
|
||||
if card in recent_scans:
|
||||
if now - recent_scans[card] < 5.0:
|
||||
logging.debug('Debouncing scan')
|
||||
continue
|
||||
recent_scans[card] = now
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user