mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 16:13:33 +08:00
UTC timestamping support in CAN driver mock; this enables stricter timestamping checks in other tests
This commit is contained in:
@@ -22,12 +22,19 @@ public:
|
|||||||
{
|
{
|
||||||
uavcan::CanFrame frame;
|
uavcan::CanFrame frame;
|
||||||
uavcan::MonotonicTime time;
|
uavcan::MonotonicTime time;
|
||||||
|
uavcan::UtcTime time_utc;
|
||||||
|
|
||||||
FrameWithTime(const uavcan::CanFrame& frame, uavcan::MonotonicTime time)
|
FrameWithTime(const uavcan::CanFrame& frame, uavcan::MonotonicTime time)
|
||||||
: frame(frame)
|
: frame(frame)
|
||||||
, time(time)
|
, 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)
|
FrameWithTime(const uavcan::CanFrame& frame, uint64_t time_usec)
|
||||||
: frame(frame)
|
: frame(frame)
|
||||||
, time(uavcan::MonotonicTime::fromUSec(time_usec))
|
, time(uavcan::MonotonicTime::fromUSec(time_usec))
|
||||||
@@ -62,7 +69,7 @@ public:
|
|||||||
{
|
{
|
||||||
uavcan::CanFrame can_frame;
|
uavcan::CanFrame can_frame;
|
||||||
EXPECT_TRUE(frame.compile(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)
|
bool matchAndPopTx(const uavcan::CanFrame& frame, uavcan::MonotonicTime tx_deadline)
|
||||||
@@ -135,6 +142,7 @@ public:
|
|||||||
rx.pop();
|
rx.pop();
|
||||||
out_frame = frame.frame;
|
out_frame = frame.frame;
|
||||||
out_ts_monotonic = frame.time;
|
out_ts_monotonic = frame.time;
|
||||||
|
out_ts_utc = frame.time_utc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -144,7 +152,12 @@ public:
|
|||||||
out_frame = frame.frame;
|
out_frame = frame.frame;
|
||||||
out_ts_monotonic = frame.time;
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user