From 153336d757c3dc8695144f6553a828aab2234a43 Mon Sep 17 00:00:00 2001 From: Smittix Date: Wed, 14 Jan 2026 13:28:07 +0000 Subject: [PATCH] Fix TSCM SDR device detection SDRFactory.detect_devices() returns SDRDevice dataclass objects, not dictionaries. Fixed to access attributes directly instead of using .get() method. Co-Authored-By: Claude Opus 4.5 --- routes/tscm.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/routes/tscm.py b/routes/tscm.py index af25302..3f5ddbd 100644 --- a/routes/tscm.py +++ b/routes/tscm.py @@ -426,15 +426,17 @@ def get_tscm_devices(): try: from utils.sdr import SDRFactory sdr_list = SDRFactory.detect_devices() - for i, sdr in enumerate(sdr_list): + for sdr in sdr_list: + # SDRDevice is a dataclass with attributes, not a dict devices['sdr_devices'].append({ - 'index': i, - 'name': sdr.get('name', f'SDR Device {i}'), - 'type': sdr.get('type', 'unknown'), - 'serial': sdr.get('serial', '') + 'index': sdr.index, + 'name': sdr.name, + 'type': sdr.sdr_type.value if hasattr(sdr.sdr_type, 'value') else str(sdr.sdr_type), + 'serial': sdr.serial, + 'driver': sdr.driver }) except ImportError: - pass + logger.debug("SDR module not available") except Exception as e: logger.warning(f"Error detecting SDR devices: {e}")