Repository navigation
fix(backend): isolate mixed transport status and add Pi CAN LED profile - #9
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression test lacks an assertion that CAN connection publishes /connected = true, so it could pass even if aggregate state updates stop reaching the UI.
1 open issue
What changed in this PR
This PR separates private UC2 transport state from aggregate UI state so individual Serial or CAN connections cannot independently report the mixed hardware bus as connected.
Changes:
- Introduces private transport state and uses it for YAML-managed physical buses.
- Adds a Pi machine profile combining Serial axes and illumination with a CAN RGB LED matrix.
- Adds regression coverage for aggregate connection status when CAN is offline.
| File | Description |
|---|---|
backend/tests/test_yaml_hardware.py |
Adds mixed-transport state publication regression coverage. |
backend/newswitch/protocols/uc2.py |
Separates private transport state from reactive public state. |
backend/newswitch/managers/uc2/yaml_runtime.py |
Creates private state for each physical transport. |
backend/newswitch/managers/uc2/rest_bus.py |
Allows the Serial driver to accept private transport state. |
backend/newswitch/managers/uc2/canopen_bus.py |
Allows the CAN driver to accept private transport state. |
backend/configs/machines/openuc2-first-cord-30059-mixed.yaml |
Defines the mixed Serial/CAN Pi hardware profile. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This pull request introduces support for distinguishing between private transport-level state and aggregate UI state in the UC2 hardware bus management. The changes ensure that internal connection status updates from individual transports (like Serial or CAN) do not incorrectly overwrite the aggregate connection state exposed to the UI, especially in mixed setups. The update includes a new configuration YAML for a mixed Serial/CAN UC2 setup and adds a regression test to verify correct state publishing behavior.
State management improvements:
UC2TransportStateclass to represent private connection state for each physical transport, separating it from the publicUC2Statewhich is now used for aggregate/UI state. (backend/newswitch/protocols/uc2.py) [1] [2]UC2RestBusandUC2CanBusto useUC2TransportStatefor their internal state, preventing direct publishing of transport connection status to the UI. (backend/newswitch/managers/uc2/rest_bus.py,backend/newswitch/managers/uc2/canopen_bus.py,backend/newswitch/managers/uc2/yaml_runtime.py) [1] [2] [3] [4]Configuration and testing:
backend/configs/machines/openuc2-first-cord-30059-mixed.yaml)backend/tests/test_yaml_hardware.py)