Skip to content

Commit

Permalink
Update daemon_rfid_reader.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Toqqi authored Dec 8, 2020
1 parent 41b53a5 commit 4e1a6fc
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 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

from Reader import Reader

Expand Down Expand Up @@ -35,6 +36,10 @@
previous_id = ""
previous_time = time.time()

# get swipe or place configuration value
sop = open('../settings/Swipe_or_Place', 'r')
swipe_or_place = sop.read().strip()

# create array for control card ids
cards = []

Expand All @@ -56,7 +61,28 @@
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:
if swipe_or_place == "PLACENOTSWIPE":
# 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 +92,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

1 comment on commit 4e1a6fc

@Toqqi
Copy link
Owner Author

@Toqqi Toqqi commented on 4e1a6fc Dec 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now reading out the Swipe_or_Place settings file, which makes the behaviour configurable. Tested and working.

Please sign in to comment.