Small things because fuck sd cards
Build, push image, and notify Watchtower / build-image (push) Successful in 3m22s
Build, push image, and notify Watchtower / notify (push) Successful in 1m24s

This commit is contained in:
2026-08-25 19:16:50 +02:00
parent 688fd26db8
commit 3753f57041
12 changed files with 139 additions and 94 deletions
+10 -4
View File
@@ -1,7 +1,7 @@
import time
import pigpio
from typing import Optional
from sensors.lock import serial_lock
from sensors.lock import safe_serial_access
class RFIDReader:
@@ -19,7 +19,10 @@ class RFIDReader:
if not self.pi.connected:
raise RuntimeError("pigpio daemon is not running. Run 'sudo systemctl start pigpiod'.")
with serial_lock:
with safe_serial_access(timeout=1.0) as acquired:
if not acquired:
raise RuntimeError("RFID: Could not acquire serial lock during initialization")
self.pi.set_mode(self.rx_pin, pigpio.INPUT)
# Clean up lingering serial sessions on this pin
@@ -34,7 +37,10 @@ class RFIDReader:
"""
Reads and accumulates bytes, returning the 10-digit Tag ID.
"""
with serial_lock:
with safe_serial_access(timeout=0.5) as acquired:
if not acquired:
return None
if not self.pi or not self.pi.connected:
return None
@@ -70,7 +76,7 @@ class RFIDReader:
return None
def close(self):
with serial_lock:
with safe_serial_access(timeout=1.0) as acquired:
if self.pi and self.pi.connected:
try:
self.pi.bb_serial_read_close(self.rx_pin)