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:
Annika Backstrom 2017-04-08 01:55:34 +00:00
parent 39fd4018f6
commit e5c4923609
2 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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()