Commit Graph

18 Commits

Author SHA1 Message Date
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 e22f26e507 AP_DroneCAN: DNA_Server: briefly document database to guide cleanup 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 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 c1f59186fa AP_DroneCAN: DNA_Server: make reset method private 2024-07-30 09:49:43 +10: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 9261f89e39 AP_DroneCAN: rename more variables, types and defines 2023-04-11 10:31:31 +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