Repository navigation
fix: validate logic capture modes before clearing data - #313
YashAnand69 wants to merge 1 commit into
Conversation
Reviewer's GuideThe capture path now resolves mode names before any state mutation or device command, preventing invalid requests from destroying an existing acquisition while preserving KeyError behavior and the valid-mode protocol. New mock-connection tests cover state preservation across channel and mode combinations and confirm unchanged behavior for all supported modes. Sequence diagram for logic analyzer capture mode validationsequenceDiagram
participant Caller
participant LogicAnalyzer
participant Device
Caller->>LogicAnalyzer: capture(channels, events, modes)
LogicAnalyzer->>LogicAnalyzer: MODES[m]
alt invalid mode
MODES[m]-->>LogicAnalyzer: KeyError
LogicAnalyzer-->>Caller: KeyError
Note over LogicAnalyzer,Device: Existing acquisition and device state remain unchanged
else valid modes
LogicAnalyzer->>LogicAnalyzer: _check_arguments(channels, events)
LogicAnalyzer->>LogicAnalyzer: stop()
LogicAnalyzer->>Device: clear_buffer(CP.MAX_SAMPLES)
LogicAnalyzer->>LogicAnalyzer: _invalidate_buffer()
LogicAnalyzer->>Device: _configure_trigger(channels)
LogicAnalyzer->>Device: capture protocol commands
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk | ⚪ Minimal · up to
|
An invalid logic-analyzer capture mode currently raises only after stopping the previous capture, clearing the device buffer and invalidating its local metadata. A typo can therefore destroy an acquisition before reporting the error.
Resolve the mode names before changing channel mappings or issuing device commands. Preserve the existing KeyError and valid-mode protocol behavior. This change does not expand the set of accepted mode names.
Validation: ten regressions fail on unchanged main and six valid-mode controls pass. All 16 new cases plus 33 existing hardware-independent CLI, Pico and gas-sensor tests pass (49 total). Configured Black, Flake8, Bandit and pydocstyle checks, package and Sphinx builds pass; existing documentation warnings remain. Tests record device commands and verify all prior channel metadata is preserved. No physical-device or full hardware integration validation was performed. Developed and tested with Codex assistance.
No matching issue ownership claim or overlapping open PR found. Capture timing, event counts and firmware protocol remain unchanged.
Summary by Sourcery
Validate logic-analyzer capture modes before modifying acquisition state or issuing device commands.
Bug Fixes:
Tests:
Summary by CodeRabbit