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)
|
GPIO.output(RFID_EN_PIN, GPIO.LOW)
|
||||||
logging.info('GPIO initialized')
|
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')
|
logging.info('Serial initialized')
|
||||||
|
|
||||||
for sig in (SIGABRT, SIGILL, SIGINT, SIGSEGV, SIGTERM):
|
for sig in (SIGABRT, SIGILL, SIGINT, SIGSEGV, SIGTERM):
|
||||||
|
@ -71,7 +71,8 @@ def reader_thread(card_data_queue):
|
||||||
except Empty:
|
except Empty:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
card = ser.readline()
|
ser.reset_input_buffer()
|
||||||
|
card = ser.read(100)
|
||||||
|
|
||||||
if not card:
|
if not card:
|
||||||
continue
|
continue
|
||||||
|
@ -83,16 +84,15 @@ def reader_thread(card_data_queue):
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logging.debug('Card read string: %s', card)
|
card = card[1:11]
|
||||||
|
|
||||||
if len(card) != 10:
|
logging.debug('Card read string: %s', card)
|
||||||
logging.debug('Card length not 10, skipping')
|
|
||||||
continue
|
|
||||||
|
|
||||||
# debounce card scans
|
# debounce card scans
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if card in recent_scans:
|
if card in recent_scans:
|
||||||
if now - recent_scans[card] < 5.0:
|
if now - recent_scans[card] < 5.0:
|
||||||
|
logging.debug('Debouncing scan')
|
||||||
continue
|
continue
|
||||||
recent_scans[card] = now
|
recent_scans[card] = now
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user