updeated to read specific card

This commit is contained in:
2025-12-08 15:45:37 +02:00
parent 9d32f43ac7
commit 02227a12e5
7 changed files with 291 additions and 28 deletions
+55 -10
View File
@@ -133,23 +133,68 @@ class CardReader:
try:
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
# Look for devices that might be card readers (keyboards, HID devices)
for device in devices:
# Card readers typically show up as keyboard input devices
if 'keyboard' in device.name.lower() or 'card' in device.name.lower() or 'reader' in device.name.lower():
Logger.info(f"CardReader: Found potential card reader: {device.name} at {device.path}")
self.device = device
return True
# If no specific card reader found, use first keyboard device
# Log all available devices for debugging
Logger.info("CardReader: Scanning input devices...")
for device in devices:
Logger.info(f" - {device.name} ({device.path})")
# Exclusion list: devices to skip (touchscreens, mice, etc.)
exclusion_keywords = [
'touch', 'touchscreen', 'mouse', 'mice', 'trackpad',
'touchpad', 'pen', 'stylus', 'video', 'button', 'lid'
]
# Priority 1: Look for devices explicitly named as card readers
for device in devices:
device_name_lower = device.name.lower()
# Skip excluded devices
if any(keyword in device_name_lower for keyword in exclusion_keywords):
Logger.info(f"CardReader: Skipping excluded device: {device.name}")
continue
# High priority: explicit card reader or RFID reader
if 'card' in device_name_lower or 'reader' in device_name_lower or 'rfid' in device_name_lower or 'hid' in device_name_lower:
capabilities = device.capabilities()
if ecodes.EV_KEY in capabilities:
Logger.info(f"CardReader: Found card reader: {device.name} at {device.path}")
self.device = device
return True
# Priority 2: Look for USB keyboard devices (but not built-in/PS2 keyboards)
# Card readers usually show as USB HID keyboards
for device in devices:
device_name_lower = device.name.lower()
# Skip excluded devices
if any(keyword in device_name_lower for keyword in exclusion_keywords):
continue
# Look for USB keyboards (card readers often appear as "USB Keyboard" or similar)
if 'usb' in device_name_lower and 'keyboard' in device_name_lower:
capabilities = device.capabilities()
if ecodes.EV_KEY in capabilities:
Logger.info(f"CardReader: Using USB keyboard device as card reader: {device.name} at {device.path}")
self.device = device
return True
# Priority 3: Use any keyboard device that hasn't been excluded
Logger.warning("CardReader: No explicit card reader found, searching for any suitable keyboard device")
for device in devices:
device_name_lower = device.name.lower()
# Skip excluded devices
if any(keyword in device_name_lower for keyword in exclusion_keywords):
continue
capabilities = device.capabilities()
if ecodes.EV_KEY in capabilities:
Logger.info(f"CardReader: Using keyboard device as card reader: {device.name}")
Logger.info(f"CardReader: Using keyboard device as card reader: {device.name} at {device.path}")
self.device = device
return True
Logger.warning("CardReader: No suitable input device found")
Logger.warning("CardReader: No suitable input device found after checking all devices")
return False
except Exception as e:
Logger.error(f"CardReader: Error finding device: {e}")
+4 -4
View File
@@ -1,10 +1,10 @@
{
"hostname": "tv-terasa",
"auth_code": "vkrxEO6eOTxkzXJBtoN4OuXc8eaX2mC3AB9ZePrnick",
"hostname": "rpi-tvholba1",
"auth_code": "73XSgIh2iBu3jaU1VOWSrYSS7c9fCPuZuRd7ygYDcjc",
"player_id": 1,
"player_name": "TV-acasa",
"player_name": "Tv-Anunturi Hol Ba1",
"playlist_id": 1,
"orientation": "Landscape",
"authenticated": true,
"server_url": "http://digi-signage.moto-adv.com"
"server_url": "http://digiserver"
}