mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 07:11:35 +08:00
Proper OTR deadlines
This commit is contained in:
@@ -64,7 +64,10 @@ public:
|
|||||||
class UAVCAN_EXPORT IOutgoingTransferRegistry
|
class UAVCAN_EXPORT IOutgoingTransferRegistry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const MonotonicDuration MinEntryLifetime;
|
||||||
|
|
||||||
virtual ~IOutgoingTransferRegistry() { }
|
virtual ~IOutgoingTransferRegistry() { }
|
||||||
|
|
||||||
virtual TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline) = 0;
|
virtual TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline) = 0;
|
||||||
virtual bool exists(DataTypeID dtid, TransferType tt) const = 0;
|
virtual bool exists(DataTypeID dtid, TransferType tt) const = 0;
|
||||||
virtual void cleanup(MonotonicTime deadline) = 0;
|
virtual void cleanup(MonotonicTime deadline) = 0;
|
||||||
|
|||||||
@@ -19,4 +19,9 @@ std::string OutgoingTransferRegistryKey::toString() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IOutgoingTransferRegistry
|
||||||
|
*/
|
||||||
|
const MonotonicDuration IOutgoingTransferRegistry::MinEntryLifetime = MonotonicDuration::fromMSec(2000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ int TransferSender::send(const uint8_t* payload, unsigned payload_len, Monotonic
|
|||||||
const OutgoingTransferRegistryKey otr_key(data_type_id_, transfer_type, dst_node_id);
|
const OutgoingTransferRegistryKey otr_key(data_type_id_, transfer_type, dst_node_id);
|
||||||
|
|
||||||
UAVCAN_ASSERT(!tx_deadline.isZero());
|
UAVCAN_ASSERT(!tx_deadline.isZero());
|
||||||
const MonotonicTime otr_deadline = tx_deadline + max_transfer_interval_ * 2;
|
const MonotonicTime otr_deadline = tx_deadline + max(max_transfer_interval_ * 2,
|
||||||
|
IOutgoingTransferRegistry::MinEntryLifetime);
|
||||||
|
|
||||||
TransferID* const tid = dispatcher_.getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
|
TransferID* const tid = dispatcher_.getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
|
||||||
if (tid == NULL)
|
if (tid == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user