-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
AP_DroneCAN: fix and clean up DNA server #27543
Conversation
Ensures the occupation mask doesn't get populated with junk if the magic is not valid.
The StorageManager read_block/write_block methods only return failure if an out of bounds access is performed. Assert statically that this does not happen. Also remove the now-impossible failed to add node state.
Node IDs >= 128 don't exist, and IDs 126 and 127 are "reserved for network maintenance tools" according to the spec.
Slightly reduces flash usage and probably is clearer.
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.
Put documentation with each bitmask and use the object directly. Node ID range checks can be removed as the bitmask itself checks and we don't expect to trip them. Substantially cleans up the code.
426be3f
to
fc3342b
Compare
Performed the following tests with a Cube Orange and 3x MatekL431 node boards:
So I am confident that GPSes will continue to work and their IDs won't change. |
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.
@bugobliterator has offered to review this PR (Sid is the original author of the code)
uint8_t crc = crc_crc8(node_data.hwid_hash, sizeof(node_data.hwid_hash)); | ||
if (crc == node_data.crc && node_data.crc != 0) { |
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.
I think we want to backport just this small fix (in minimal form) for 4.5.x
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.
What is the reasoning behind removing the checks if storage operations were successful?
Actually, nevermind. Had a look through the StorageManager, we write to files on separate thread, and don't return error on io failures. So certainly logical to remove the runtime checks. |
Please see commit messages for details.
Fixes the following issues:
Does not yet address the elephant in the room of multiple servers using the same storage. That will come next; this all makes that easier.
Tested on SITL and a Cube Orange on the bench using various configurations of AP_Periph nodes. Tested that the DNA database is preserved and that the DroneCAN GUI tool still works properly as well.