mirror of https://github.com/ArduPilot/ardupilot
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:
parent
df283a1739
commit
f2d66886c9
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue