mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 06:53:34 +08:00
Fixed publication timeouts (Server, Publisher, GenericPublisher)
This commit is contained in:
@@ -94,13 +94,18 @@ class GenericPublisher
|
||||
}
|
||||
|
||||
public:
|
||||
GenericPublisher(Scheduler& scheduler, IMarshalBufferProvider& buffer_provider,
|
||||
GenericPublisher(Scheduler& scheduler, IMarshalBufferProvider& buffer_provider, MonotonicDuration tx_timeout,
|
||||
MonotonicDuration max_transfer_interval = TransferSender::getDefaultMaxTransferInterval())
|
||||
: max_transfer_interval_(max_transfer_interval)
|
||||
, tx_timeout_(getDefaultTxTimeout())
|
||||
, tx_timeout_(tx_timeout)
|
||||
, scheduler_(scheduler)
|
||||
, buffer_provider_(buffer_provider)
|
||||
{ }
|
||||
{
|
||||
setTxTimeout(tx_timeout);
|
||||
#if UAVCAN_DEBUG
|
||||
assert(getTxTimeout() == tx_timeout); // Making sure default values are OK
|
||||
#endif
|
||||
}
|
||||
|
||||
~GenericPublisher() { }
|
||||
|
||||
@@ -116,13 +121,15 @@ public:
|
||||
return genericPublish(message, transfer_type, dst_node_id, &tid, blocking_deadline);
|
||||
}
|
||||
|
||||
static MonotonicDuration getDefaultTxTimeout() { return MonotonicDuration::fromUSec(2500); }// 2500ms --> 400Hz max
|
||||
static MonotonicDuration getMinTxTimeout() { return MonotonicDuration::fromUSec(200); }
|
||||
static MonotonicDuration getMaxTxTimeout() { return MonotonicDuration::fromMSec(60000); }
|
||||
|
||||
MonotonicDuration getTxTimeout() const { return tx_timeout_; }
|
||||
void setTxTimeout(MonotonicDuration tx_timeout)
|
||||
{
|
||||
tx_timeout_ = std::max(tx_timeout, getMinTxTimeout());
|
||||
tx_timeout = std::max(tx_timeout, getMinTxTimeout());
|
||||
tx_timeout = std::min(tx_timeout, getMaxTxTimeout());
|
||||
tx_timeout_ = tx_timeout;
|
||||
}
|
||||
|
||||
Scheduler& getScheduler() const { return scheduler_; }
|
||||
|
||||
@@ -18,11 +18,13 @@ public:
|
||||
typedef DataType_ DataType;
|
||||
|
||||
Publisher(Scheduler& scheduler, IMarshalBufferProvider& buffer_provider,
|
||||
MonotonicDuration tx_timeout = BaseType::getDefaultTxTimeout(),
|
||||
MonotonicDuration tx_timeout = getDefaultTxTimeout(),
|
||||
MonotonicDuration max_transfer_interval = TransferSender::getDefaultMaxTransferInterval())
|
||||
: BaseType(scheduler, buffer_provider, max_transfer_interval)
|
||||
: BaseType(scheduler, buffer_provider, tx_timeout, max_transfer_interval)
|
||||
{
|
||||
BaseType::setTxTimeout(tx_timeout);
|
||||
#if UAVCAN_DEBUG
|
||||
assert(getTxTimeout() == tx_timeout); // Making sure default values are OK
|
||||
#endif
|
||||
StaticAssert<DataTypeKind(DataType::DataTypeKind) == DataTypeKindMessage>::check();
|
||||
}
|
||||
|
||||
@@ -41,8 +43,10 @@ public:
|
||||
return publish(message, TransferTypeMessageUnicast, dst_node_id);
|
||||
}
|
||||
|
||||
using BaseType::getDefaultTxTimeout;
|
||||
static MonotonicDuration getDefaultTxTimeout() { return MonotonicDuration::fromMSec(5); } // 5 ms --> 200 Hz max
|
||||
|
||||
using BaseType::getMinTxTimeout;
|
||||
using BaseType::getMaxTxTimeout;
|
||||
using BaseType::getTxTimeout;
|
||||
using BaseType::setTxTimeout;
|
||||
using BaseType::getScheduler;
|
||||
|
||||
@@ -58,10 +58,12 @@ private:
|
||||
public:
|
||||
Server(Scheduler& scheduler, IAllocator& allocator, IMarshalBufferProvider& buffer_provider)
|
||||
: SubscriberType(scheduler, allocator)
|
||||
, publisher_(scheduler, buffer_provider)
|
||||
, publisher_(scheduler, buffer_provider, getDefaultTxTimeout())
|
||||
, callback_()
|
||||
, response_failure_count_(0)
|
||||
{
|
||||
assert(getTxTimeout() == getDefaultTxTimeout()); // Making sure it is valid
|
||||
|
||||
StaticAssert<DataTypeKind(DataType::DataTypeKind) == DataTypeKindService>::check();
|
||||
}
|
||||
|
||||
@@ -81,6 +83,13 @@ public:
|
||||
|
||||
using SubscriberType::stop;
|
||||
|
||||
static MonotonicDuration getDefaultTxTimeout() { return MonotonicDuration::fromMSec(1000); }
|
||||
static MonotonicDuration getMinTxTimeout() { return PublisherType::getMinTxTimeout(); }
|
||||
static MonotonicDuration getMaxTxTimeout() { return PublisherType::getMaxTxTimeout(); }
|
||||
|
||||
MonotonicDuration getTxTimeout() const { return publisher_.getTxTimeout(); }
|
||||
void setTxTimeout(MonotonicDuration tx_timeout) { publisher_.setTxTimeout(tx_timeout); }
|
||||
|
||||
uint32_t getRequestFailureCount() const { return SubscriberType::getFailureCount(); }
|
||||
uint32_t getResponseFailureCount() const { return response_failure_count_; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user