-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Add back CANNODE_NODE_ID for setting a static node ID #25669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
d0a92b7
to
58a6260
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on a couple of our CAN products. Verified setting CANNODE_NODE_ID allows the user to configure the Node ID. If this is later set back to 0 (ID is allocated) the flight controller will continue to allocate that same ID (this is how DNA works). Verified firmware updating continues to work.
Users must take care to avoid configuring two nodes with the same ID.
Need to add docs now.
58a6260
to
a406407
Compare
/en/dronecan/ark_cannode.md
/en/dronecan/ark_flow.md
/en/dronecan/ark_flow_mr.md
/en/dronecan/ark_gps.md
/en/dronecan/ark_rtk_gps.md
/en/dronecan/index.md
/en/dronecan/px4_cannode_fw.md
|
In its current state, it will only use the static ID if no ID was allocated on boot. We discussed overriding that if the static ID is set. What do you think? |
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/px4-dev-call-oct-15-2025-team-sync-and-community-q-a/47650/1 |
} | ||
|
||
// Assign the static node ID if no dynamic allocation is used. Do wen't override a valid node ID from the bootloader? | ||
if (node_id == 0 && cannode_node_id > 0 && cannode_node_id <= 127) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (node_id == 0 && cannode_node_id > 0 && cannode_node_id <= 127) { | |
if (node_id == 0 && cannode_node_id > 0 && cannode_node_id <= uavcan::NodeID::Max) { |
param_get(param_find("CANNODE_NODE_ID"), &cannode_node_id); | ||
|
||
// Check if the static node ID is in range | ||
if (cannode_node_id < 0 || cannode_node_id > 127) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (cannode_node_id < 0 || cannode_node_id > 127) { | |
if (cannode_node_id < 0 || cannode_node_id > uavcan::NodeID::Max) { |
// Persist the node ID for the bootloader | ||
bootloader_app_shared_t shared_write = {}; | ||
shared_write.node_id = node_id; | ||
shared_write.bus_speed = bitrate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's not really any error checking or validation on the bitrate, it might be safer to do this a bit later after the node has actually started spinning successfully.
For example you could do it here, and only if there was no dynamic node ID allocation. https://github.com/AlexKlimaj/PX4-Autopilot/blob/a4064072c793787aa9aac149c376bbf3c613d8b0/src/drivers/uavcannode/UavcanNode.cpp#L558-L580
This PR adds back the CANNODE_NODE_ID param for setting a static node ID on cannodes. This will need careful testing as the last time I dove into this, ran into too many edge cases that could prevent a node from booting.