AP_DroneCAN: DNA_Server: fix handling of empty entry

Replaces the check for a CRC of 0 with a check that the hwid is 0.
Substantially reduces 1/256 chance that a particular node ID couldn't be
stored.
This commit is contained in:
Thomas Watson 2024-07-13 15:53:11 -05:00 committed by Randy Mackay
parent df283a1739
commit f2d66886c9
1 changed files with 3 additions and 1 deletions

View File

@ -202,8 +202,10 @@ bool AP_DroneCAN_DNA_Server::isValidNodeDataAvailable(uint8_t node_id)
{ {
NodeData node_data; NodeData node_data;
readNodeData(node_data, node_id); readNodeData(node_data, node_id);
uint8_t empty_hwid[sizeof(NodeData::hwid_hash)] = {0};
uint8_t crc = crc_crc8(node_data.hwid_hash, sizeof(node_data.hwid_hash)); uint8_t crc = crc_crc8(node_data.hwid_hash, sizeof(node_data.hwid_hash));
if (crc == node_data.crc && node_data.crc != 0) { if (crc == node_data.crc && memcmp(&node_data.hwid_hash[0], &empty_hwid[0], sizeof(empty_hwid)) != 0) {
return true; return true;
} }
return false; return false;