From cd8519321b5f283c3ca133137479e4af9ff8333f Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sat, 13 Jul 2024 12:50:11 -0500 Subject: [PATCH] AP_DroneCAN: DNA_Server: search for valid nodes after magic check Ensures the occupation mask doesn't get populated with junk if the magic is not valid. --- libraries/AP_DroneCAN/AP_DroneCAN_DNA_Server.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/AP_DroneCAN/AP_DroneCAN_DNA_Server.cpp b/libraries/AP_DroneCAN/AP_DroneCAN_DNA_Server.cpp index 12262859c5..8c4337f351 100644 --- a/libraries/AP_DroneCAN/AP_DroneCAN_DNA_Server.cpp +++ b/libraries/AP_DroneCAN/AP_DroneCAN_DNA_Server.cpp @@ -217,13 +217,6 @@ bool AP_DroneCAN_DNA_Server::init(uint8_t own_unique_id[], uint8_t own_unique_id { //Read the details from AP_DroneCAN server_state = HEALTHY; - /* Go through our records and look for valid NodeData, to initialise - occupation mask */ - for (uint8_t i = 0; i <= MAX_NODE_ID; i++) { - if (isValidNodeDataAvailable(i)) { - occupation_mask.set(i); - } - } // Check if the magic is present uint16_t magic; @@ -239,6 +232,15 @@ bool AP_DroneCAN_DNA_Server::init(uint8_t own_unique_id[], uint8_t own_unique_id GCS_SEND_TEXT(MAV_SEVERITY_INFO, "UC DNA database reset"); reset(); } + + /* Go through our records and look for valid NodeData, to initialise + occupation mask */ + for (uint8_t i = 0; i <= MAX_NODE_ID; i++) { + if (isValidNodeDataAvailable(i)) { + occupation_mask.set(i); + } + } + // Making sure that the server is started with the same node ID const uint8_t stored_own_node_id = getNodeIDForUniqueID(own_unique_id, own_unique_id_len); static bool reset_done;