tag-reader: update to pi-rc522 2.1
This version of pi-rc522 gives us a wait_for_tag() method, greatly reducing CPU usage.
This commit is contained in:
parent
39fd4018f6
commit
e5c4923609
@ -1,3 +1,7 @@
|
|||||||
pi-rc522==1.1.0
|
appdirs==1.4.3
|
||||||
|
packaging==16.8
|
||||||
|
pi-rc522==2.1.0
|
||||||
|
pyparsing==2.2.0
|
||||||
RPi.GPIO==0.6.3
|
RPi.GPIO==0.6.3
|
||||||
SPI-Py==1.0
|
six==1.10.0
|
||||||
|
spidev==3.2
|
||||||
|
@ -3,11 +3,21 @@ from pirc522 import RFID
|
|||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import signal
|
||||||
|
|
||||||
GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
|
|
||||||
rdr = RFID()
|
rdr = RFID()
|
||||||
|
|
||||||
|
def sigint_handler(signal, frame):
|
||||||
|
rdr.cleanup()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, sigint_handler)
|
||||||
|
signal.signal(signal.SIGTERM, sigint_handler)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
rdr.wait_for_tag()
|
||||||
(error, tag_type) = rdr.request()
|
(error, tag_type) = rdr.request()
|
||||||
if not error:
|
if not error:
|
||||||
(error, uid) = rdr.anticoll()
|
(error, uid) = rdr.anticoll()
|
||||||
|
Loading…
Reference in New Issue
Block a user