mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 17:33:33 +08:00
INode class. Publisher, Subscriber, ServiceServer, ServiceClient now accept INode in constructor instead of the bunch of independent params. Self NodeID now being configured via setNodeID() method instead of constructor param
This commit is contained in:
@@ -21,7 +21,7 @@ void DeadlineHandler::startWithDeadline(MonotonicTime deadline)
|
||||
|
||||
void DeadlineHandler::startWithDelay(MonotonicDuration delay)
|
||||
{
|
||||
startWithDeadline(scheduler_.getMonotonicTimestamp() + delay);
|
||||
startWithDeadline(scheduler_.getMonotonicTime() + delay);
|
||||
}
|
||||
|
||||
void DeadlineHandler::stop()
|
||||
@@ -80,7 +80,7 @@ bool DeadlineScheduler::doesExist(const DeadlineHandler* mdh) const
|
||||
return false;
|
||||
}
|
||||
|
||||
MonotonicTime DeadlineScheduler::pollAndGetMonotonicTimestamp(ISystemClock& sysclock)
|
||||
MonotonicTime DeadlineScheduler::pollAndGetMonotonicTime(ISystemClock& sysclock)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ MonotonicTime DeadlineScheduler::getEarliestDeadline() const
|
||||
MonotonicTime Scheduler::computeDispatcherSpinDeadline(MonotonicTime spin_deadline) const
|
||||
{
|
||||
const MonotonicTime earliest = std::min(deadline_scheduler_.getEarliestDeadline(), spin_deadline);
|
||||
const MonotonicTime ts = getMonotonicTimestamp();
|
||||
const MonotonicTime ts = getMonotonicTime();
|
||||
if (earliest > ts)
|
||||
{
|
||||
if (ts - earliest > deadline_resolution_)
|
||||
@@ -148,7 +148,7 @@ int Scheduler::spin(MonotonicTime deadline)
|
||||
if (retval < 0)
|
||||
break;
|
||||
|
||||
const MonotonicTime ts = deadline_scheduler_.pollAndGetMonotonicTimestamp(getSystemClock());
|
||||
const MonotonicTime ts = deadline_scheduler_.pollAndGetMonotonicTime(getSystemClock());
|
||||
pollCleanup(ts, retval);
|
||||
if (ts >= deadline)
|
||||
break;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
void Timer::handleDeadline(MonotonicTime current_timestamp)
|
||||
void Timer::handleDeadline(MonotonicTime current)
|
||||
{
|
||||
assert(!isRunning());
|
||||
|
||||
@@ -18,7 +18,7 @@ void Timer::handleDeadline(MonotonicTime current_timestamp)
|
||||
startWithDeadline(scheduled_time + period_);
|
||||
|
||||
// Application can re-register the timer with different params, it's OK
|
||||
handleTimerEvent(TimerEvent(scheduled_time, current_timestamp));
|
||||
handleTimerEvent(TimerEvent(scheduled_time, current));
|
||||
}
|
||||
|
||||
void Timer::startOneShotWithDeadline(MonotonicTime deadline)
|
||||
|
||||
@@ -69,7 +69,7 @@ void Dispatcher::handleFrame(const CanRxFrame& can_frame)
|
||||
}
|
||||
|
||||
if ((frame.getDstNodeID() != NodeID::Broadcast) &&
|
||||
(frame.getDstNodeID() != getSelfNodeID()))
|
||||
(frame.getDstNodeID() != getNodeID()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ int Dispatcher::spin(MonotonicTime deadline)
|
||||
int Dispatcher::send(const Frame& frame, MonotonicTime tx_deadline, MonotonicTime blocking_deadline,
|
||||
CanTxQueue::Qos qos)
|
||||
{
|
||||
if (frame.getSrcNodeID() != getSelfNodeID())
|
||||
if (frame.getSrcNodeID() != getNodeID())
|
||||
{
|
||||
assert(0);
|
||||
return -1;
|
||||
@@ -188,4 +188,14 @@ void Dispatcher::unregisterServiceResponseListener(TransferListenerBase* listene
|
||||
lsrv_resp_.remove(listener);
|
||||
}
|
||||
|
||||
bool Dispatcher::setNodeID(NodeID nid)
|
||||
{
|
||||
if (nid.isUnicast() && !self_node_id_.isValid())
|
||||
{
|
||||
self_node_id_ = nid;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime
|
||||
MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id,
|
||||
TransferID tid)
|
||||
{
|
||||
Frame frame(data_type_.getID(), transfer_type, dispatcher_.getSelfNodeID(), dst_node_id, 0, tid);
|
||||
Frame frame(data_type_.getID(), transfer_type, dispatcher_.getNodeID(), dst_node_id, 0, tid);
|
||||
|
||||
if (frame.getMaxPayloadLen() >= payload_len) // Single Frame Transfer
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user