Allow sygnal socket can interface to handle any number of MCMs#18
Allow sygnal socket can interface to handle any number of MCMs#18
Conversation
|
For the case where there may not be a subsystem associated with an MCM (as is documented in LEV05 interface doc) it looks like the SygnalMcmInterface strictly expects two-args for the constructor (id.bus_id & id.subsystem_id). I guess the assumption is that if no subsystem ID is passed it will just get assigned subsystem ID = 0 which may be fine. This comment is based on the assumption that the interface document is the source of truth and whether or not the MCM will always have an associated bus and subsystem ID. Not blocking, but worth the discussion |
In order to support LEV02, Sygnal added subsystem_id to all their CAN message definitions. See this PR. So it is safe to assume we will always need a subsystem ID because we now need to send one in the CAN message no matter what. |
Remove
McmSystemwrapper; support arbitrary MCM configurationssygnal_can_interface_libsygnal_mcm_interface.hppget_bus_address()andget_subsystem_id()public getterssygnal_interface_socketcanto look up interfaces by identity without needing an external indexsygnal_interface_socketcan.hppstruct McmSystem, which grouped two named members (mcm_0,mcm_1) under a shared bus addressSygnalMcmInterfacealready carries its own bus and subsystem IDs internallystruct McmId { uint8_t bus_id; uint8_t subsystem_id; }, used only at construction timestd::array<McmSystem, 2> mcm_systems_becomesstd::vector<SygnalMcmInterface> mcms_const std::vector<McmId> &sygnal_interface_socketcan.cppmcms_by emplacing oneSygnalMcmInterface(id.bus_id, id.subsystem_id)per entryparsecollapses the nestedmcm_0/mcm_1calls into a single range loopget_interface_stateandget_sygnal_mcm_statereplace their hardcodedif (subsystem_id == 0) ... else if (subsystem_id == 1)ladders withstd::find_ifover the flat list using the new getterssygnal_interface_socketcan_test.cppSygnalInterfaceSocketcanconstruction site to pass aMcmIdlist equivalent to the old hardcoded defaults{0, 2, 5}, verifies subsystem 5 is reachable after a heartbeat, and checks that unconfigured subsystem 1 correctly returnsstd::nulloptsygnal_can_interface_ros2The ROS2 node now drives the MCM topology from parameters. Two new parallel
int_arrayparams,mcm_bus_addresses(default[1, 1, 2, 2]) andmcm_subsystem_ids(default[0, 1, 0, 1]), describe the list of endpoints. The defaults reproduce the previous behavior so existing deployments need no config changes.on_configure, the two arrays are zipped into astd::vector<McmId>(with a length-mismatch guard) and passed to theSygnalInterfaceSocketcanconstructormcm_heartbeat_entries_is populated from the same list, replacing the four hardcoded assignmentsstd::array<McmHeartbeatEntry, 4>tostd::vector<McmHeartbeatEntry>timerCallback,createDiagnosticsMessage, lifecycle activate/deactivate/cleanup) already iterate the container generically and needed no changes