Commit Graph

28 Commits

Author SHA1 Message Date
Thomas Watson
5a1c825ea2 AP_DroneCAN: DNAServer: clean up and optimize allocation 2024-09-10 12:35:04 +10:00
Thomas Watson
4427cbee71 AP_DroneCAN: DNAServer: avoid clearing node ID during allocation
Not necessary and wastes flash.
2024-09-10 12:35:04 +10:00
Thomas Watson
89c9e59c55 AP_DroneCAN: DNA_Server: polish db methods
No compiler output change.
2024-09-02 11:53:24 +10:00
Thomas Watson
7c5a46bac2 AP_DroneCAN: DNA_Server: arrange db methods into more logical order 2024-08-20 10:22:55 +10:00
Thomas Watson
b38766c469 AP_DroneCAN: DNA_Server: clarify comments with consistent terminology 2024-08-20 10:22:55 +10:00
Thomas Watson
9669b4e85d AP_DroneCAN: DNA_Server: rename db methods to use consistent terminology
Also use snake_case like the rest of Ardupilot.
2024-08-20 10:22:55 +10:00
Thomas Watson
ddf74e2da4 AP_DroneCAN: DNA_Server: rename node record structure
Rename NodeData to NodeRecord to provide a more specific name and match
the record term used in the comments. Also nominally allows stuff to be
associated with the nodes that's not the record, as expanding the record
is hard.

Additionally, rename the `hwid` field to `uid` as that's what's used in
the rest of the code.
2024-08-20 10:22:55 +10:00
Thomas Watson
e12f345bae AP_DroneCAN: DNA_Server: make lower level database tasks private
All the higher level database operations need to be locked for the whole
duration of the operation, so nobody should be using the lower-level
tasks or raw read/write functions. We can also remove the locks from
them.

The database can now safely be used by multiple servers.
2024-08-13 09:58:44 +10:00
Thomas Watson
4097e9fa42 AP_DroneCAN: DNA_Server: move allocation operation to db
Must be locked for the whole operation due to the find free/add
read-modify-write.

Preserves the previous behavior of sending back an ID of 0 in case of
allocation failure, for better or worse.
2024-08-13 09:58:44 +10:00
Thomas Watson
f406c62449 AP_DroneCAN: DNA_Server: move node info update operation to db
Must be locked for the whole operation due to the occupied check and
addition read-modify-write.
2024-08-13 09:58:44 +10:00
Thomas Watson
e79437d04a AP_DroneCAN: DNA_Server: move init operation into db
Must be locked for the whole operation due to the get/add
read-modify-write.
2024-08-13 09:58:44 +10:00
Thomas Watson
01e285c681 AP_DroneCAN: DNA_Server: move database tasks to db class
The server should not have raw read/write access to the database so the
database needs to take over the tasks.
2024-08-13 09:58:44 +10:00
Thomas Watson
a9774d2334 AP_DroneCAN: DNA_Server: move storage read/write to its own class
There is (currently) only one storage area that is used by all servers,
so it needs to be managed by its own class shared among them.

The occupied mask is also moved as it reflects the storage contents and
so can't be stored by each server.
2024-08-13 09:58:44 +10:00
Thomas Watson
60a9f1722c AP_DroneCAN: DNA_Server: unify bitmask handling
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.
2024-07-30 09:49:43 +10:00
Thomas Watson
56593574a9 AP_DroneCAN: DNA_Server: miscellaneous cleanup 2024-07-30 09:49:43 +10:00
Thomas Watson
5e0bb99dbb 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.
2024-07-30 09:49:43 +10:00
Thomas Watson
9aeab7b424 AP_DroneCAN: DNA_Server: use 0 as unknown ID
Slightly reduces flash usage and probably is clearer.
2024-07-30 09:49:43 +10:00
Thomas Watson
8d57533f1c AP_DroneCAN: DNA_Server: fix cases involving use of invalid node IDs 2024-07-30 09:49:43 +10:00
Thomas Watson
485a9387b1 AP_DroneCAN: DNA_Server: clean up storage failure handling
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.
2024-07-30 09:49:43 +10:00
Thomas Watson
cd8519321b 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.
2024-07-30 09:49:43 +10:00
Iampete1
ff00d562fe AP_DroneCAN: DNA_Server: log driver index in CAND 2024-02-16 21:55:07 +11:00
Peter Barker
dd4d017717 AP_DroneCAN: allow compilation with HAL_LOGGING_ENABLED false 2024-01-17 18:25:55 +11:00
bugobliterator
34494bb7d1 AP_DroneCAN: pass all the variables to AP_DroneCAN_DNA_Server by value
we were using the values by the AP_DroneCAN object, but the members might
not have been initialised if they are out of order
2023-07-29 08:27:27 +09:00
Andrew Tridgell
e811cf86eb AP_DroneCAN: text messages and more defines 2023-04-11 10:31:31 +10:00
Andrew Tridgell
9261f89e39 AP_DroneCAN: rename more variables, types and defines 2023-04-11 10:31:31 +10:00
Andrew Tridgell
dec4dff1d8 AP_DroneCAN: fixed valgrind errors 2023-04-08 07:11:23 +10:00
Andrew Tridgell
8b096c2987 AP_DroneCAN: rename AP_UAVCAN to AP_DroneCAN 2023-04-08 07:11:23 +10:00
Andrew Tridgell
1efd640624 AP_DroneCAN: rename source files for AP_DroneCAN 2023-04-08 07:11:23 +10:00