5 #ifndef UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED
6 #define UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED
13 #include <uavcan/protocol/GlobalTimeSync.hpp>
44 , iface_index_(iface_index)
51 const int res = pub_.
init(priority);
68 if (!prev_tx_utc_.
isZero())
83 iface_prev_pub_mono_ = current_time;
85 const bool long_period = since_prev_pub.
toMSec() >= protocol::GlobalTimeSync::MAX_BROADCASTING_PERIOD_MS;
87 protocol::GlobalTimeSync msg;
88 msg.previous_transmission_timestamp_usec = long_period ? 0 : prev_tx_utc_.
toUSec();
91 UAVCAN_TRACE(
"GlobalTimeSyncMaster",
"Publishing %llu iface=%i tid=%i",
92 static_cast<unsigned long long>(msg.previous_transmission_timestamp_usec),
93 int(iface_index_),
int(tid.
get()));
109 if (
frame.getDataTypeID() == dtid_ &&
111 frame.isStartOfTransfer() &&
frame.isEndOfTransfer() &&
114 iface_masters_[iface]->setTxTimestamp(
frame.getUtcTimestamp());
146 , initialized_(false)
166 return -ErrUnknownDataType;
168 dtid_ = desc->
getID();
174 if (!iface_masters_[i].isConstructed())
178 res = iface_masters_[i]->init(priority);
186 initialized_ = res >= 0;
214 const int res =
init();
228 if (since_prev_pub.
toMSec() < protocol::GlobalTimeSync::MIN_BROADCASTING_PERIOD_MS)
230 UAVCAN_TRACE(
"GlobalTimeSyncMaster",
"Publication skipped");
233 prev_pub_mono_ = current_time;
241 const int tid_res = getNextTransferID(tid);
250 const int res = iface_masters_[i]->publish(tid, current_time);
262 #endif // UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED