Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementing stop on removal for RC522 #1122

Merged
merged 1 commit into from
Feb 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions scripts/daemon_rfid_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import time
import re
import signal
s-martin marked this conversation as resolved.
Show resolved Hide resolved

from Reader import Reader

Expand Down Expand Up @@ -56,7 +57,27 @@
else:
ids = ""


# handler for RFID reading no cardid
def handler(signum, frame):
logger.info('No RFID Signal detected.')
try:
# force pause the player script
logger.info('Trigger Pause Force')
subprocess.call([dir_path + '/playout_controls.sh -c=playerpauseforce -v=0.1'], shell=True)
except OSError as e:
logger.info('Execution of Pause failed.')


# associate the handler to signal alarm
signal.signal(signal.SIGALRM, handler)

while True:
# slow down the card reading while loop
time.sleep(0.2)
# enable the signal alarm (if no card is present for 1 second)
signal.alarm(1)

# reading the card id
# NOTE: it's been reported that KKMOON Reader might need the following line altered.
# Instead of:
Expand All @@ -66,6 +87,10 @@
# See here for (German ;) details:
# https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/551
cardid = reader.reader.readCard()

# disable the alarm after a successful read
signal.alarm(0)

try:
# start the player script and pass on the cardid (but only if new card or otherwise
# "same_id_delay" seconds have passed)
Expand Down