diff --git a/9_Firmware/9_3_GUI/requirements_v7.txt b/9_Firmware/9_3_GUI/requirements_v7.txt index 0a5ea08..72f9db3 100644 --- a/9_Firmware/9_3_GUI/requirements_v7.txt +++ b/9_Firmware/9_3_GUI/requirements_v7.txt @@ -17,6 +17,3 @@ scipy>=1.10 # Tracking / clustering (optional) scikit-learn>=1.2 filterpy>=1.4 - -# CRC validation (optional) -crcmod>=1.7 diff --git a/9_Firmware/9_3_GUI/v7/hardware.py b/9_Firmware/9_3_GUI/v7/hardware.py index b9b4109..d855a4b 100644 --- a/9_Firmware/9_3_GUI/v7/hardware.py +++ b/9_Firmware/9_3_GUI/v7/hardware.py @@ -32,10 +32,23 @@ def _load_radar_protocol(): if mod_name in sys.modules: return sys.modules[mod_name] proto_path = pathlib.Path(__file__).resolve().parent.parent / "radar_protocol.py" + if not proto_path.is_file(): + raise FileNotFoundError( + f"radar_protocol.py not found at expected location: {proto_path}" + ) spec = importlib.util.spec_from_file_location(mod_name, proto_path) + if spec is None or spec.loader is None: + raise ImportError( + f"Cannot create module spec for radar_protocol.py at {proto_path}" + ) mod = importlib.util.module_from_spec(spec) + # Register before exec so cyclic imports resolve correctly, but remove on failure sys.modules[mod_name] = mod - spec.loader.exec_module(mod) # type: ignore[union-attr] + try: + spec.loader.exec_module(mod) + except Exception: + sys.modules.pop(mod_name, None) + raise return mod diff --git a/9_Firmware/9_3_GUI/v7/workers.py b/9_Firmware/9_3_GUI/v7/workers.py index c467c98..4e491a0 100644 --- a/9_Firmware/9_3_GUI/v7/workers.py +++ b/9_Firmware/9_3_GUI/v7/workers.py @@ -131,6 +131,10 @@ class RadarDataWorker(QThread): self._byte_count = 0 self._error_count = 0 + # Monotonically increasing target ID — persisted across frames so map + # JS can key markers/trails by a stable ID. + self._next_target_id = 0 + def stop(self): self._running = False if self._acquisition: @@ -244,7 +248,7 @@ class RadarDataWorker(QThread): ) target = RadarTarget( - id=len(targets), + id=self._next_target_id, range=range_m, velocity=velocity_ms, azimuth=azimuth, @@ -254,6 +258,7 @@ class RadarDataWorker(QThread): snr=snr, timestamp=frame.timestamp, ) + self._next_target_id += 1 targets.append(target) # DBSCAN clustering