ConfigHWIDs: decode MAVn_DEVID parameters to human-readable strings - #3762
ConfigHWIDs: decode MAVn_DEVID parameters to human-readable strings#3762Greninja44 wants to merge 2 commits into
Conversation
fallenmi
left a comment
There was a problem hiding this comment.
The lookup values do not match the full device IDs that ArduPilot actually publishes. The MAVn_DEVID parameter metadata added in ArduPilot #29762 defines, for example, USB/SERIAL0 as 65542, SERIAL1 as 65798, NET_P1 as 131078, CAN_D1_UC_S1 as 196614, and SCR_SDEV1 as 262150. This patch instead tests and maps 6, 14, 174, 334, and 494.
I compiled the exact Device.cs from head 112fd6a9 into a small external consumer and fed it the real values from ArduPilot's parameter declaration. Every tested family remains undecoded and returns the raw number:
65542 -> 65542 (expected USB0)
65798 -> 65798 (expected SERIAL1)
131078 -> 131078 (expected NET_P1)
196614 -> 196614 (expected CAN_D1_UC_S1)
196622 -> 196622 (expected CAN_D2_UC_S1)
262150 -> 262150 (expected SCR_SDEV1)
The small values in the new tests omit the device-type and address fields from AP_HAL::Device::make_bus_id; they are not the values stored in the parameter. Please map the full IDs (or decode the bit fields algorithmically), update the regressions to use ArduPilot's emitted values, and include the currently omitted CAN D1/D2 UC S2/S3 and scripting SDEV3 entries. Replacing the enum constants with the upstream full values makes the same consumer pass.
Disclosure: I used OpenAI Codex to inspect the exact revisions and run this real-source mapping oracle; I verified the result locally.
ArduPilot added MAVn_DEVID params identifying which serial/network/ CAN/scripting device a MAVLink channel's MAVn_* params apply to. Add a devid lookup table so the HW ID page shows names like SERIAL1, NET_P1, CAN_D1_UC_S1 instead of a raw number. Fixes ArduPilot#3761
112fd6a to
3ac813d
Compare
Previous review (2026-08-30, at head 3ac813d)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Reviewed at head
Correct and unaffected: |
The previous commit enumerated small literal values (6, 14, 22, ...) that omitted the devtype and address fields from AP_HAL::Device::make_bus_id, so no real vehicle's MAVn_DEVID value ever matched.
Decode is now closed-form on the existing bus_type/bus/address/devtype bitfields (devid = bus_type | bus<<3 | address<<8 | devtype<<16), matching AP_SerialManager::UARTState::get_device_id() and the values ArduPilot publishes in GCS_MAVLink_Parameters.cpp: UART -> SERIAL0 (USB)/SERIALn, NETWORKING -> NET_Pn, CANBUS -> CAN_D{bus}_UC_S{n}, SCRIPTING -> SCR_SDEVn. This also covers ports ArduPilot didn't explicitly enumerate (SERIAL10+, CAN D1/D2 UC S2/S3, SCR_SDEV3, future NET_P5+) without further hand-maintenance.
Updated DeviceInfoTests.cs to use the real published devid values.
|
You're both right, thanks for catching this. Pushed a fix (3294d86):
I verified the new decode logic against the exact constants from your review (65542/65798/131078/196614/196622/262150/262406) and they match. I wasn't able to get a full msbuild/vstest run working in this environment, so I'd appreciate a look at CI once it runs, and agree a vstest step would be worth adding separately. |
|
Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Re-reviewed at head
One thing I'd ask for before merge, and two small notes:
Test coverage is otherwise good. Two small gaps if you're touching it anyway: nothing passes a non-MAV parameter name, so the new Nice turnaround — thanks for taking the algorithmic approach. |
Summary
ArduPilot recently added
MAVn_DEVIDparameters (see ArduPilot/ardupilot#29762) which identify which serial/USB/network/CAN/scripting device a MAVLink channel'sMAVn_*parameters correspond to. The HW ID page didn't know about this new parameter family, so those rows fell through to the IMU device-type decode and showed a meaningless raw number instead of a readable name.This adds a
mavlink_devidlookup (matching the naming used by ArduPilot/MAVProxy:SERIAL1,USB0,NET_P1,CAN_D1_UC_S1,SCR_SDEV1, etc.) and wires it into the existingDeviceInfo.DevTypedecode path used by the HW ID grid, following the same pattern already used for compass/IMU/baro/airspeed device types.Fixes #3761
Mapping added
Unrecognized values fall back to the raw number, consistent with how the other device-type enums already behave.
Test plan
MissionPlannerTests/Utilities/DeviceInfoTests.cscovering all 19 mappings plus the unrecognized-value fallback.Device.cs/DeviceInfo.csunmodified) that all 19 mappings, the unknown-value fallback, and the pre-existing compass/IMU/baro/airspeed/UAVCAN decode paths are unaffected.