mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 05:43:33 +08:00
Time synchronization message update: 1. field prev_utc_usec renamed to a more human-readable name; 2. UTC is no longer required, but rather recommended
This commit is contained in:
@@ -56,11 +56,12 @@ int GlobalTimeSyncMaster::IfaceMaster::publish(TransferID tid, MonotonicTime cur
|
||||
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();
|
||||
msg.previous_transmission_timestamp_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()));
|
||||
static_cast<unsigned long long>(msg.previous_transmission_timestamp_usec),
|
||||
int(iface_index_), int(tid.get()));
|
||||
return pub_.broadcast(msg, tid);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace uavcan
|
||||
|
||||
void GlobalTimeSyncSlave::adjustFromMsg(const ReceivedDataStructure<protocol::GlobalTimeSync>& msg)
|
||||
{
|
||||
UAVCAN_ASSERT(msg.prev_utc_usec > 0);
|
||||
const UtcDuration adjustment = UtcTime::fromUSec(msg.prev_utc_usec) - prev_ts_utc_;
|
||||
UAVCAN_ASSERT(msg.previous_transmission_timestamp_usec > 0);
|
||||
const UtcDuration adjustment = UtcTime::fromUSec(msg.previous_transmission_timestamp_usec) - prev_ts_utc_;
|
||||
|
||||
UAVCAN_TRACE("GlobalTimeSyncSlave", "Adjustment: usec=%lli snid=%i iface=%i suppress=%i",
|
||||
static_cast<long long>(adjustment.toUSec()),
|
||||
@@ -58,7 +58,7 @@ void GlobalTimeSyncSlave::processMsg(const ReceivedDataStructure<protocol::Globa
|
||||
{
|
||||
if (state_ == Adjust)
|
||||
{
|
||||
const bool msg_invalid = msg.prev_utc_usec == 0;
|
||||
const bool msg_invalid = msg.previous_transmission_timestamp_usec == 0;
|
||||
const bool wrong_tid = prev_tid_.computeForwardDistance(msg.getTransferID()) != 1;
|
||||
const bool wrong_timing = since_prev_msg.toMSec() > protocol::GlobalTimeSync::MAX_PUBLICATION_PERIOD_MS;
|
||||
if (msg_invalid || wrong_tid || wrong_timing)
|
||||
|
||||
Reference in New Issue
Block a user