some fixes again
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
import logging
|
||||
|
||||
from python_app.hardware_full.librevna_backends import LibreVnaBackend, MockLibreVnaBackend, NativeLibreVnaBackend
|
||||
from python_app.hardware_full.librevna_driver.models import SweepResult
|
||||
from python_app.models.run_config_model import RadarSweepModel
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class LibreVnaService:
|
||||
@@ -41,9 +44,16 @@ class LibreVnaService:
|
||||
strict_protocol_version=self.strict_protocol_version,
|
||||
)
|
||||
self._driver_available = True
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
# 'native' demands real hardware — never substitute synthetic data.
|
||||
if mode == "native":
|
||||
raise
|
||||
# 'auto' falls back to the mock backend ONLY when the native driver
|
||||
# library itself is unavailable (a dev host without the USB stack) —
|
||||
# this is not device-absence (that surfaces later from open()). Log it
|
||||
# loudly so it is never a silent surprise; a deployed appliance should
|
||||
# set driver_mode='native' to forbid the fallback entirely.
|
||||
logger.warning("LibreVNA native backend unavailable; falling back to mock (mode=auto): %s", exc)
|
||||
self._backend = MockLibreVnaBackend()
|
||||
self._using_mock_backend = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user