mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 15:13:33 +08:00
RX frames have two timestamps: monotonic - for protocol timings management; utc - for application-level timestamping
This commit is contained in:
@@ -19,11 +19,13 @@ namespace uavcan
|
||||
|
||||
struct CanRxFrame : public CanFrame
|
||||
{
|
||||
uint64_t timestamp;
|
||||
uint64_t ts_monotonic;
|
||||
uint64_t ts_utc;
|
||||
uint8_t iface_index;
|
||||
|
||||
CanRxFrame()
|
||||
: timestamp(0)
|
||||
: ts_monotonic(0)
|
||||
, ts_utc(0)
|
||||
, iface_index(0)
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -137,11 +137,13 @@ struct Frame
|
||||
|
||||
struct RxFrame : public Frame
|
||||
{
|
||||
uint_fast64_t timestamp;
|
||||
uint_fast64_t ts_monotonic;
|
||||
uint_fast64_t ts_utc;
|
||||
uint_fast8_t iface_index;
|
||||
|
||||
RxFrame()
|
||||
: timestamp(0)
|
||||
: ts_monotonic(0)
|
||||
, ts_utc(0)
|
||||
, iface_index(0)
|
||||
{ }
|
||||
|
||||
@@ -149,7 +151,8 @@ struct RxFrame : public Frame
|
||||
{
|
||||
if (!Frame::parse(can_frame))
|
||||
return false;
|
||||
timestamp = can_frame.timestamp;
|
||||
ts_monotonic = can_frame.ts_monotonic;
|
||||
ts_utc = can_frame.ts_utc;
|
||||
iface_index = can_frame.iface_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ private:
|
||||
enum TidRelation { TID_SAME, TID_REPEAT, TID_FUTURE };
|
||||
enum { IFACE_INDEX_NOTSET = 0xFF };
|
||||
|
||||
uint64_t prev_transfer_timestamp_;
|
||||
uint64_t this_transfer_timestamp_;
|
||||
uint64_t transfer_interval_;
|
||||
uint64_t prev_transfer_ts_monotonic_;
|
||||
uint64_t this_transfer_ts_monotonic_;
|
||||
uint64_t first_frame_ts_utc_;
|
||||
uint64_t transfer_interval_; // TODO: make 32 bit
|
||||
ITransferBufferManager* bufmgr_;
|
||||
TransferBufferManagerKey bufmgr_key_;
|
||||
TransferID tid_;
|
||||
@@ -48,8 +49,9 @@ private:
|
||||
|
||||
public:
|
||||
TransferReceiver()
|
||||
: prev_transfer_timestamp_(0)
|
||||
, this_transfer_timestamp_(0)
|
||||
: prev_transfer_ts_monotonic_(0)
|
||||
, this_transfer_ts_monotonic_(0)
|
||||
, first_frame_ts_utc_(0)
|
||||
, transfer_interval_(DEFAULT_TRANSFER_INTERVAL)
|
||||
, bufmgr_(NULL)
|
||||
, iface_index_(IFACE_INDEX_NOTSET)
|
||||
@@ -57,8 +59,9 @@ public:
|
||||
{ }
|
||||
|
||||
TransferReceiver(ITransferBufferManager* bufmgr, const TransferBufferManagerKey& bufmgr_key)
|
||||
: prev_transfer_timestamp_(0)
|
||||
, this_transfer_timestamp_(0)
|
||||
: prev_transfer_ts_monotonic_(0)
|
||||
, this_transfer_ts_monotonic_(0)
|
||||
, first_frame_ts_utc_(0)
|
||||
, transfer_interval_(DEFAULT_TRANSFER_INTERVAL)
|
||||
, bufmgr_(bufmgr)
|
||||
, bufmgr_key_(bufmgr_key)
|
||||
@@ -74,8 +77,9 @@ public:
|
||||
TransferReceiver& operator=(const TransferReceiver& rhs)
|
||||
{
|
||||
cleanup();
|
||||
prev_transfer_timestamp_ = rhs.prev_transfer_timestamp_;
|
||||
this_transfer_timestamp_ = rhs.this_transfer_timestamp_;
|
||||
prev_transfer_ts_monotonic_ = rhs.prev_transfer_ts_monotonic_;
|
||||
this_transfer_ts_monotonic_ = rhs.this_transfer_ts_monotonic_;
|
||||
first_frame_ts_utc_ = rhs.first_frame_ts_utc_;
|
||||
transfer_interval_ = rhs.transfer_interval_;
|
||||
bufmgr_ = rhs.bufmgr_;
|
||||
tid_ = rhs.tid_;
|
||||
@@ -89,7 +93,8 @@ public:
|
||||
|
||||
ResultCode addFrame(const RxFrame& frame);
|
||||
|
||||
uint64_t getLastTransferTimestamp() const { return prev_transfer_timestamp_; }
|
||||
uint64_t getLastTransferTimestampMonotonic() const { return prev_transfer_ts_monotonic_; }
|
||||
uint64_t getLastTransferTimestampUtc() const { return first_frame_ts_utc_; }
|
||||
|
||||
uint64_t getInterval() const { return transfer_interval_; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user