Skip to content

Commit

Permalink
AP_DroneCAN: DNA_Server: make lower level database tasks private
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tpwrules committed Aug 5, 2024
1 parent bb43a8b commit 8433249
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions libraries/AP_DroneCAN/AP_DroneCAN_DNA_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void AP_DroneCAN_DNA_Server::Database::readNodeData(NodeData &data, uint8_t node
return;
}

WITH_SEMAPHORE(sem);
storage.read_block(&data, NODEDATA_LOC(node_id), sizeof(struct NodeData));
}

Expand All @@ -92,7 +91,6 @@ void AP_DroneCAN_DNA_Server::Database::writeNodeData(const NodeData &data, uint8
return;
}

WITH_SEMAPHORE(sem);
storage.write_block(NODEDATA_LOC(node_id), &data, sizeof(struct NodeData));
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_DroneCAN/AP_DroneCAN_DNA_Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AP_DroneCAN_DNA_Server
// handle the allocation message. returns the new node ID.
uint8_t handleAllocation(uint8_t node_id, const uint8_t unique_id[]);

private:
//Generates 6Byte long hash from the specified unique_id
void getHash(NodeData &node_data, const uint8_t unique_id[], uint8_t size) const;

Expand All @@ -61,7 +62,6 @@ class AP_DroneCAN_DNA_Server
//Finds next available free Node, starting from preferred NodeID
uint8_t findFreeNodeID(uint8_t preferred);

private:
//Look in the storage and check if there's a valid Server Record there
bool isValidNodeDataAvailable(uint8_t node_id);

Expand Down

0 comments on commit 8433249

Please sign in to comment.