mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 02:13:33 +08:00
TransferReceiver timing fix
This commit is contained in:
@@ -21,6 +21,8 @@ public:
|
||||
static const uint16_t MinTransferIntervalMSec = 1;
|
||||
static const uint16_t MaxTransferIntervalMSec = 0xFFFF;
|
||||
static const uint16_t DefaultTransferIntervalMSec = 1000;
|
||||
static const uint16_t MessageMaxTFallbackMSec = 1000;
|
||||
static const uint16_t ServiceTFallbackMSec = 500;
|
||||
|
||||
static MonotonicDuration getDefaultTransferInterval()
|
||||
{
|
||||
@@ -34,7 +36,7 @@ private:
|
||||
|
||||
enum { IfaceIndexNotSet = MaxCanIfaces };
|
||||
|
||||
enum { ErrorCntMask = 31 };
|
||||
enum { ErrorCntMask = 15 };
|
||||
enum { IfaceIndexMask = MaxCanIfaces };
|
||||
|
||||
MonotonicTime prev_transfer_ts_;
|
||||
@@ -48,14 +50,18 @@ private:
|
||||
TransferID tid_; // 1 byte field
|
||||
|
||||
// 1 byte aligned bitfields:
|
||||
uint8_t tt_service_ : 1;
|
||||
uint8_t next_toggle_ : 1;
|
||||
uint8_t iface_index_ : 2;
|
||||
mutable uint8_t error_cnt_ : 5;
|
||||
mutable uint8_t error_cnt_ : 4;
|
||||
|
||||
bool isInitialized() const { return iface_index_ != IfaceIndexNotSet; }
|
||||
|
||||
bool isMidTransfer() const { return buffer_write_pos_ > 0; }
|
||||
|
||||
MonotonicDuration getTFallback() const;
|
||||
MonotonicDuration getTTimeout() const;
|
||||
|
||||
void registerError() const;
|
||||
|
||||
TidRelation getTidRelation(const RxFrame& frame) const;
|
||||
@@ -72,14 +78,21 @@ public:
|
||||
transfer_interval_msec_(DefaultTransferIntervalMSec),
|
||||
this_transfer_crc_(0),
|
||||
buffer_write_pos_(0),
|
||||
tt_service_(false),
|
||||
next_toggle_(false),
|
||||
iface_index_(IfaceIndexNotSet),
|
||||
error_cnt_(0)
|
||||
{
|
||||
#if UAVCAN_DEBUG
|
||||
StaticAssert<sizeof(TransferReceiver) == 32>::check();
|
||||
#endif
|
||||
}
|
||||
{ }
|
||||
|
||||
TransferReceiver(const TransferType transfer_type) :
|
||||
transfer_interval_msec_(DefaultTransferIntervalMSec),
|
||||
this_transfer_crc_(0),
|
||||
buffer_write_pos_(0),
|
||||
tt_service_((transfer_type == TransferTypeServiceRequest) || (transfer_type == TransferTypeServiceResponse)),
|
||||
next_toggle_(false),
|
||||
iface_index_(IfaceIndexNotSet),
|
||||
error_cnt_(0)
|
||||
{ }
|
||||
|
||||
bool isTimedOut(MonotonicTime current_ts) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user