mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 23:13:34 +08:00
Using transfer priorities in protocol:: classes
This commit is contained in:
@@ -145,8 +145,10 @@ public:
|
||||
* Once started, the node can't stop.
|
||||
* If the node failed to start up, it's recommended to destroy the current node instance and start over.
|
||||
* Returns negative error code.
|
||||
* @param node_status_transfer_priority Transfer priority that will be used for outgoing NodeStatus messages.
|
||||
* Normal priority is used by default.
|
||||
*/
|
||||
int start();
|
||||
int start(const TransferPriority node_status_transfer_priority = TransferPriorityNormal);
|
||||
|
||||
#if !UAVCAN_TINY
|
||||
/**
|
||||
@@ -260,7 +262,8 @@ public:
|
||||
|
||||
template <std::size_t MemPoolSize_, unsigned OutgoingTransferRegistryStaticEntries,
|
||||
unsigned OutgoingTransferMaxPayloadLen>
|
||||
int Node<MemPoolSize_, OutgoingTransferRegistryStaticEntries, OutgoingTransferMaxPayloadLen>::start()
|
||||
int Node<MemPoolSize_, OutgoingTransferRegistryStaticEntries, OutgoingTransferMaxPayloadLen>::start(
|
||||
const TransferPriority priority)
|
||||
{
|
||||
if (started_)
|
||||
{
|
||||
@@ -274,7 +277,7 @@ int Node<MemPoolSize_, OutgoingTransferRegistryStaticEntries, OutgoingTransferMa
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
res = proto_nsp_.startAndPublish();
|
||||
res = proto_nsp_.startAndPublish(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
goto fail;
|
||||
@@ -322,7 +325,7 @@ checkNetworkCompatibility(NetworkCompatibilityCheckResult& result)
|
||||
}
|
||||
|
||||
NetworkCompatibilityChecker checker(*this);
|
||||
StaticAssert<(sizeof(checker) < 2048)>::check();
|
||||
StaticAssert<(sizeof(checker) < 2048)>::check(); // Making sure that the code footprint doesn't explode
|
||||
res = checker.execute();
|
||||
result = checker.getResult();
|
||||
return res;
|
||||
|
||||
@@ -100,22 +100,26 @@ public:
|
||||
/**
|
||||
* Allows to change the priority of outgoing transfers.
|
||||
* Note that only High, Normal and Low priorities can be used; Service priority is not available for messages.
|
||||
* Attempt to use Service priority will result in assertion failure in debug builds, and it will have no
|
||||
* effect in release builds.
|
||||
* Returns negative error code if priority cannot be set, non-negative on success.
|
||||
*/
|
||||
void setPriority(const TransferPriority prio)
|
||||
int setPriority(const TransferPriority prio)
|
||||
{
|
||||
if (prio < NumTransferPriorities && prio != TransferPriorityService)
|
||||
{
|
||||
TransferSender* const ts = getTransferSender();
|
||||
TransferSender* const ts = getTransferSender(); // TODO: Static TransferSender?
|
||||
if (ts != NULL)
|
||||
{
|
||||
ts->setPriority(prio);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -ErrLogic;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
return -ErrInvalidParam;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,11 +58,14 @@ public:
|
||||
* @param hardware_version Hardware version information, where unique_id must be set correctly.
|
||||
* @param preferred_node_id Node ID that the application would like to take; set to broadcast (zero) if
|
||||
* the application doesn't have any preference (this is default).
|
||||
* @param transfer_priority Transfer priority, Normal by default.
|
||||
* @return Zero on success
|
||||
* Negative error code on failure
|
||||
* -ErrLogic if 1. the node is not in passive mode or 2. the client is already started
|
||||
*/
|
||||
int start(const protocol::HardwareVersion& hardware_version, const NodeID preferred_node_id = NodeID::Broadcast);
|
||||
int start(const protocol::HardwareVersion& hardware_version,
|
||||
const NodeID preferred_node_id = NodeID::Broadcast,
|
||||
const TransferPriority transfer_priority = TransferPriorityNormal);
|
||||
|
||||
/**
|
||||
* Use this method to determine when allocation is complete.
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
* Starts the provider and immediately broadcasts uavcan.protocol.NodeStatus.
|
||||
* Returns negative error code.
|
||||
*/
|
||||
int startAndPublish();
|
||||
int startAndPublish(TransferPriority priority = TransferPriorityNormal);
|
||||
|
||||
/**
|
||||
* Publish the message uavcan.protocol.NodeStatus right now, out of schedule.
|
||||
|
||||
Reference in New Issue
Block a user