int GlobalTimeSyncMaster::IfaceMaster::publish(TransferID tid, MonotonicTime current_time) { UAVCAN_ASSERT(pub_.getTransferSender()->getCanIOFlags() == CanIOFlagLoopback); UAVCAN_ASSERT(pub_.getTransferSender()->getIfaceMask() == (1 << iface_index_)); const MonotonicDuration since_prev_pub = current_time - iface_prev_pub_mono_; iface_prev_pub_mono_ = current_time; UAVCAN_ASSERT(since_prev_pub.isPositive()); const bool long_period = since_prev_pub.toMSec() >= protocol::GlobalTimeSync::MAX_PUBLICATION_PERIOD_MS; protocol::GlobalTimeSync msg; msg.prev_utc_usec = long_period ? 0 : prev_tx_utc_.toUSec(); prev_tx_utc_ = UtcTime(); UAVCAN_TRACE("GlobalTimeSyncMaster", "Publishing %llu iface=%i tid=%i", static_cast<unsigned long long>(msg.prev_utc_usec), int(iface_index_), int(tid.get())); return pub_.broadcast(msg, tid); }
bool operator==(TransferID rhs) const { return get() == rhs.get(); }