Skip to content

fix(backend): isolate mixed transport status and add Pi CAN LED profile - #9

Merged
gokugiant merged 2 commits into
mainfrom
codex/pi-mixed-serial-can-led
Nov 13, 2026
Merged

gokugiant merged 2 commits into
mainfrom
codex/pi-mixed-serial-can-led

Conversation

@gokugiant

Copy link
Copy Markdown
Contributor

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:

  • Introduced a new UC2TransportState class to represent private connection state for each physical transport, separating it from the public UC2State which is now used for aggregate/UI state. (backend/newswitch/protocols/uc2.py) [1] [2]
  • Updated UC2RestBus and UC2CanBus to use UC2TransportState for 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:

  • Added a new YAML configuration file for a mixed Serial/CAN UC2 setup, documenting the hardware mapping and initial settings. (backend/configs/machines/openuc2-first-cord-30059-mixed.yaml)
  • Added an asynchronous regression test to ensure that private transport state changes do not incorrectly publish a connected state when the aggregate bus is not fully online. (backend/tests/test_yaml_hardware.py)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread backend/tests/test_yaml_hardware.py Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@gokugiant
gokugiant merged commit 534cd0e into main Nov 13, 2026
3 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants