fix: use importlib for radar_protocol import; downgrade noisy log levels to DEBUG

Agent-Logs-Url: https://github.com/NawfalMotii79/PLFM_RADAR/sessions/8acb5f68-51fa-4632-a73b-0188b876bed1

Co-authored-by: JJassonn69 <83615043+JJassonn69@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-12 19:09:23 +00:00
committed by GitHub
parent b394f6bc49
commit 56d0ea2883
2 changed files with 30 additions and 19 deletions
+28 -14
View File
@@ -13,9 +13,10 @@ and 'SET'...'END' binary settings protocol has been removed — it was
incompatible with the FPGA register interface.
"""
import sys
import os
import importlib.util
import logging
import pathlib
import sys
from typing import ClassVar
from .models import USB_AVAILABLE
@@ -24,18 +25,31 @@ if USB_AVAILABLE:
import usb.core
import usb.util
# Import production protocol layer — single source of truth for FPGA comms
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from radar_protocol import ( # noqa: F401 — re-exported for v7 package
FT2232HConnection,
ReplayConnection,
RadarProtocol,
Opcode,
RadarAcquisition,
RadarFrame,
StatusResponse,
DataRecorder,
)
def _load_radar_protocol():
"""Load radar_protocol.py by absolute path without mutating sys.path."""
mod_name = "radar_protocol"
if mod_name in sys.modules:
return sys.modules[mod_name]
proto_path = pathlib.Path(__file__).resolve().parent.parent / "radar_protocol.py"
spec = importlib.util.spec_from_file_location(mod_name, proto_path)
mod = importlib.util.module_from_spec(spec)
sys.modules[mod_name] = mod
spec.loader.exec_module(mod) # type: ignore[union-attr]
return mod
_rp = _load_radar_protocol()
# Re-exported for the v7 package — single source of truth for FPGA comms
FT2232HConnection = _rp.FT2232HConnection
ReplayConnection = _rp.ReplayConnection
RadarProtocol = _rp.RadarProtocol
Opcode = _rp.Opcode
RadarAcquisition = _rp.RadarAcquisition
RadarFrame = _rp.RadarFrame
StatusResponse = _rp.StatusResponse
DataRecorder = _rp.DataRecorder
logger = logging.getLogger(__name__)
+2 -5
View File
@@ -64,7 +64,7 @@ class MapBridge(QObject):
@pyqtSlot(str)
def logFromJS(self, message: str):
logger.info(f"[JS] {message}")
logger.debug(f"[JS] {message}")
@property
def is_ready(self) -> bool:
@@ -578,10 +578,7 @@ document.addEventListener('DOMContentLoaded', function() {{
return
data = [t.to_dict() for t in targets]
js_payload = json.dumps(data).replace("\\", "\\\\").replace("'", "\\'")
logger.info(
"set_targets: %d targets, JSON len=%d, first 200 chars: %s",
len(targets), len(js_payload), js_payload[:200],
)
logger.debug("set_targets: %d targets", len(targets))
self._status_label.setText(f"{len(targets)} targets tracked")
self._run_js(f"updateTargets('{js_payload}')")