mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-29 00:24:07 +08:00
UTC timestamping support in CAN driver mock; this enables stricter timestamping checks in other tests
This commit is contained in:
parent
8debad440e
commit
2d6fc2a5bd
@ -22,12 +22,19 @@ public:
|
||||
{
|
||||
uavcan::CanFrame frame;
|
||||
uavcan::MonotonicTime time;
|
||||
uavcan::UtcTime time_utc;
|
||||
|
||||
FrameWithTime(const uavcan::CanFrame& frame, uavcan::MonotonicTime time)
|
||||
: frame(frame)
|
||||
, time(time)
|
||||
{ }
|
||||
|
||||
FrameWithTime(const uavcan::CanFrame& frame, uavcan::MonotonicTime time, uavcan::UtcTime time_utc)
|
||||
: frame(frame)
|
||||
, time(time)
|
||||
, time_utc(time_utc)
|
||||
{ }
|
||||
|
||||
FrameWithTime(const uavcan::CanFrame& frame, uint64_t time_usec)
|
||||
: frame(frame)
|
||||
, time(uavcan::MonotonicTime::fromUSec(time_usec))
|
||||
@ -62,7 +69,7 @@ public:
|
||||
{
|
||||
uavcan::CanFrame can_frame;
|
||||
EXPECT_TRUE(frame.compile(can_frame));
|
||||
rx.push(FrameWithTime(can_frame, frame.getMonotonicTimestamp()));
|
||||
rx.push(FrameWithTime(can_frame, frame.getMonotonicTimestamp(), frame.getUtcTimestamp()));
|
||||
}
|
||||
|
||||
bool matchAndPopTx(const uavcan::CanFrame& frame, uavcan::MonotonicTime tx_deadline)
|
||||
@ -135,6 +142,7 @@ public:
|
||||
rx.pop();
|
||||
out_frame = frame.frame;
|
||||
out_ts_monotonic = frame.time;
|
||||
out_ts_utc = frame.time_utc;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -144,7 +152,12 @@ public:
|
||||
out_frame = frame.frame;
|
||||
out_ts_monotonic = frame.time;
|
||||
}
|
||||
out_ts_utc = enable_utc_timestamping ? iclock.getUtc() : uavcan::UtcTime();
|
||||
|
||||
// Let's just all pretend that this code is autogenerated, instead of being carefully designed by a human.
|
||||
if (out_ts_utc.isZero())
|
||||
{
|
||||
out_ts_utc = enable_utc_timestamping ? iclock.getUtc() : uavcan::UtcTime();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user