mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-19 18:49:08 +08:00
Configurable priority in high-level protocol logic classes
This commit is contained in:
parent
f48c16d1ef
commit
35fd634282
@ -396,7 +396,8 @@ public:
|
||||
* @return Negative error code.
|
||||
*/
|
||||
int start(NodeInfoRetriever& node_info_retriever,
|
||||
const FirmwareFilePath& arg_common_path_prefix = FirmwareFilePath())
|
||||
const FirmwareFilePath& arg_common_path_prefix = FirmwareFilePath(),
|
||||
const TransferPriority priority = TransferPriority::OneHigherThanLowest)
|
||||
{
|
||||
/*
|
||||
* Configuring the node info retriever
|
||||
@ -423,7 +424,7 @@ public:
|
||||
/*
|
||||
* Initializing the client
|
||||
*/
|
||||
res = begin_fw_update_client_.init();
|
||||
res = begin_fw_update_client_.init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
|
||||
@ -46,14 +46,13 @@ class UAVCAN_EXPORT GlobalTimeSyncMaster : protected LoopbackFrameListenerBase
|
||||
UAVCAN_ASSERT(iface_index < MaxCanIfaces);
|
||||
}
|
||||
|
||||
int init(TransferPriority priority = TransferPriority::OneLowerThanHighest)
|
||||
int init(TransferPriority priority)
|
||||
{
|
||||
const int res = pub_.init();
|
||||
const int res = pub_.init(priority);
|
||||
if (res >= 0)
|
||||
{
|
||||
pub_.getTransferSender().setIfaceMask(uint8_t(1 << iface_index_));
|
||||
pub_.getTransferSender().setCanIOFlags(CanIOFlagLoopback);
|
||||
pub_.setPriority(priority);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -152,7 +151,7 @@ public:
|
||||
* Must be called before the master can be used.
|
||||
* Returns negative error code.
|
||||
*/
|
||||
int init()
|
||||
int init(const TransferPriority priority = TransferPriority::OneLowerThanHighest)
|
||||
{
|
||||
if (initialized_)
|
||||
{
|
||||
@ -176,7 +175,7 @@ public:
|
||||
{
|
||||
iface_masters_[i].construct<INode&, uint8_t>(node_, i);
|
||||
}
|
||||
res = iface_masters_[i]->init();
|
||||
res = iface_masters_[i]->init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
|
||||
@ -94,14 +94,13 @@ public:
|
||||
* Must be called once before use.
|
||||
* Returns negative error code.
|
||||
*/
|
||||
int init(TransferPriority priority = TransferPriority::OneHigherThanLowest)
|
||||
int init(const TransferPriority priority = TransferPriority::Lowest)
|
||||
{
|
||||
const int res = logmsg_pub_.init();
|
||||
const int res = logmsg_pub_.init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
logmsg_pub_.setPriority(priority); // Fixed priority
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -346,7 +346,7 @@ public:
|
||||
* Destroy the object to stop it.
|
||||
* Returns negative error code.
|
||||
*/
|
||||
int start()
|
||||
int start(const TransferPriority priority = TransferPriority::OneHigherThanLowest)
|
||||
{
|
||||
int res = NodeStatusMonitor::start();
|
||||
if (res < 0)
|
||||
@ -354,7 +354,7 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
res = get_node_info_client_.init();
|
||||
res = get_node_info_client_.init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
|
||||
@ -61,7 +61,7 @@ public:
|
||||
* Starts the provider and immediately broadcasts uavcan.protocol.NodeStatus.
|
||||
* Returns negative error code.
|
||||
*/
|
||||
int startAndPublish(TransferPriority priority = TransferPriority::Default);
|
||||
int startAndPublish(const TransferPriority priority = TransferPriority::Default);
|
||||
|
||||
/**
|
||||
* Publish the message uavcan.protocol.NodeStatus right now, out of schedule.
|
||||
|
||||
@ -48,7 +48,8 @@ public:
|
||||
* @param short_reason Short ASCII string that describes the reason of the panic, 7 characters max.
|
||||
* If the string exceeds 7 characters, it will be truncated.
|
||||
*/
|
||||
void panic(const char* short_reason_description)
|
||||
void panic(const char* short_reason_description,
|
||||
const TransferPriority priority = TransferPriority::Default)
|
||||
{
|
||||
msg_.reason_text.clear();
|
||||
const char* p = short_reason_description;
|
||||
@ -64,6 +65,8 @@ public:
|
||||
|
||||
UAVCAN_TRACE("PanicBroadcaster", "Panicking with reason '%s'", getReason().c_str());
|
||||
|
||||
pub_.setPriority(priority);
|
||||
|
||||
publishOnce();
|
||||
startPeriodic(MonotonicDuration::fromMSec(protocol::Panic::BROADCASTING_PERIOD_MS));
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ public:
|
||||
static const TransferPriority MiddleLower;
|
||||
static const TransferPriority OneHigherThanLowest;
|
||||
static const TransferPriority OneLowerThanHighest;
|
||||
static const TransferPriority Lowest;
|
||||
|
||||
TransferPriority() : value_(0xFF) { }
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ void NodeStatusProvider::handleGetNodeInfoRequest(const protocol::GetNodeInfo::R
|
||||
rsp = node_info_;
|
||||
}
|
||||
|
||||
int NodeStatusProvider::startAndPublish(TransferPriority priority)
|
||||
int NodeStatusProvider::startAndPublish(const TransferPriority priority)
|
||||
{
|
||||
if (!isNodeInfoInitialized())
|
||||
{
|
||||
|
||||
@ -19,6 +19,7 @@ const TransferPriority TransferPriority::Default((1U << BitLen) / 2);
|
||||
const TransferPriority TransferPriority::MiddleLower((1U << BitLen) / 2 + (1U << BitLen) / 4);
|
||||
const TransferPriority TransferPriority::OneHigherThanLowest(NumericallyMax - 1);
|
||||
const TransferPriority TransferPriority::OneLowerThanHighest(NumericallyMin + 1);
|
||||
const TransferPriority TransferPriority::Lowest(NumericallyMax);
|
||||
|
||||
/**
|
||||
* TransferID
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user