diff --git a/packages/embeddedci/CHANGELOG.md b/packages/embeddedci/CHANGELOG.md index ad43e20..2c77695 100644 --- a/packages/embeddedci/CHANGELOG.md +++ b/packages/embeddedci/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog — `embeddedci` +## Unreleased + +- `Capabilities.scope` is False on the digital-only board. Current firmware lists `signal` on every + board; it only stands for the scope on firmware without the `analog` flag. + ## 2.13.0 - `generate()` on firmware 3.9.1+ (`Capabilities.generate16`) sends the volts (or microamps on diff --git a/packages/embeddedci/src/embeddedci/benchpod/capabilities.py b/packages/embeddedci/src/embeddedci/benchpod/capabilities.py index a65b30c..236ca9c 100644 --- a/packages/embeddedci/src/embeddedci/benchpod/capabilities.py +++ b/packages/embeddedci/src/embeddedci/benchpod/capabilities.py @@ -285,7 +285,11 @@ def from_status(cls, status: Mapping[str, Any]) -> "Capabilities": caps = status.get("caps") if isinstance(caps, (list, tuple)): names = {str(x).lower() for x in caps} - c.scope = c.scope or ("signal" in names or "scope" in names) + # "signal" stood for the scope on firmware that predates the analog flag. Current + # firmware lists it on every board, the digital-only one included, and names "scope" + # itself, so it only counts when the status has no analog flag. + legacy = _as_bool(status, "analog") is None + c.scope = c.scope or "scope" in names or (legacy and "signal" in names) c.analyzer = c.analyzer or ("la" in names or "analyzer" in names) c.serial = c.serial or ("uart" in names or "serial" in names) # The DAC/gateware features. Firmware advertises these in status.caps[] built from diff --git a/packages/embeddedci/tests/test_capabilities_scope.py b/packages/embeddedci/tests/test_capabilities_scope.py new file mode 100644 index 0000000..cfa43e6 --- /dev/null +++ b/packages/embeddedci/tests/test_capabilities_scope.py @@ -0,0 +1,21 @@ +"""Capabilities.scope from a pod's status: the digital-only board has no scope.""" + +from embeddedci.benchpod.capabilities import Capabilities + + +def test_digital_board_has_no_scope(): + # Firmware 3.6+ lists "signal" on every board and names "scope" itself on the analog one. + status = {"board": "stm32h563", "adc_bits": 16, "analog": False, + "caps": ["signal", "gpio", "power", "la", "analyzer", "command"]} + assert Capabilities.from_status(status).scope is False + + +def test_analog_board_has_the_scope(): + status = {"board": "stm32h563", "adc_bits": 16, "analog": True, + "caps": ["signal", "la", "analog", "scope", "dac"]} + assert Capabilities.from_status(status).scope is True + + +def test_firmware_without_the_analog_flag_keeps_signal_as_scope(): + status = {"board": "stm32h563", "adc_bits": 16, "caps": ["signal", "la"]} + assert Capabilities.from_status(status).scope is True