Skip to content

Source Physical Topology From GRCAN.CANdo, Remove can_topology.json - #13

Open
coderask wants to merge 1 commit into
mainfrom
derive-topology-from-cando
Open

Source Physical Topology From GRCAN.CANdo, Remove can_topology.json#13
coderask wants to merge 1 commit into
mainfrom
derive-topology-from-cando

Conversation

@coderask

Copy link
Copy Markdown

Source Physical Topology From GRCAN.CANdo

Problem and Scope

Physical bus wiring — which devices are wired to which CAN bus — lived in this repo's standalone Web/can_topology.json, duplicating information that now belongs in GRCAN.CANdo. Firmware#532 adds a hand-editable physical topology section to GRCAN.CANdo as the single source of truth, leaving can_topology.json a stale duplicate.

Description

Repoints the viewer at the CANdo's own physical topology section and deletes the duplicate JSON:

  • candoDocument.js: parses the physical topology: section (already preserved verbatim in the Bus ID span) into _physicalTopology and exposes getPhysicalTopology() returning Map<bus, Set<node>>.
  • physicalTopology.js: load() now reads from GrcanDocument.getPhysicalTopology() instead of fetching can_topology.json. Public API (isOnBus, getNodesForBus, isLoaded, validate) and the Debugger/ALL exemptions are unchanged.
  • viewer.js: refreshes topology inside renderHierarchy (and reRenderLocal) once the ref's CANdo is loaded, so the Graph View tracks the viewed ref.
  • Deletes Web/can_topology.json and updates README.md.

Gotchas and Limitations

Topology now tracks whichever ref is loaded rather than a single static file — a net improvement, but it means an old ref whose CANdo predates the physical topology section will report no topology (enforcement fails open, same as a missing file today). Bus and node names must still match the Bus ID and GR ID sections by hand; validate() warns on drift.

Testing

  • HOOTL testing
  • HITL testing
  • Human tested

Testing Details

  • node --check passes on all Web/*.js.
  • Parsed the real GRCAN.CANdo through GrcanDocument.getPhysicalTopology(): Primary (13), Data (20), Charger (5) match the file; Testing correctly absent; returned map is a defensive copy.
  • Exercised PhysicalTopology end-to-end: isOnBus true for wired nodes, false for unwired, always true for Debugger; getNodesForBus correct; unlisted bus returns []; validate() runs clean against the device registry.

Larger Impact

One source of truth for CAN configuration. Physical wiring is edited alongside the logical bus and routing definitions in GRCAN.CANdo, and the viewer no longer carries a separate data file to keep in sync.

Additional Context and Ticket

Companion to Firmware#532, which introduced the physical topology section. Realizes the follow-up noted there. Original migration of web out of Firmware: Firmware#521.

The physical bus wiring now lives in the physical topology section of
GRCAN.CANdo (Firmware), which is the single source of truth. Teach
GrcanDocument to parse that section and expose getPhysicalTopology(),
repoint PhysicalTopology at the document instead of fetching the JSON,
refresh it on each ref load, and delete the now-duplicate
can_topology.json.
@coderask
coderask requested a review from dchansen06 as a code owner July 31, 2026 04:23
@coderask coderask added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant