mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 05:11:36 +08:00
Merge branch 'master' into dynamic_node_id_raft
This commit is contained in:
@@ -84,12 +84,15 @@ static Stream& operator<<(Stream& s, const ServiceCallResult<DataType>& scr)
|
|||||||
*/
|
*/
|
||||||
class ServiceClientBase : protected DeadlineHandler
|
class ServiceClientBase : protected DeadlineHandler
|
||||||
{
|
{
|
||||||
|
const DataTypeDescriptor* data_type_descriptor_; ///< This will be initialized at the time of first call
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MonotonicDuration request_timeout_;
|
MonotonicDuration request_timeout_;
|
||||||
bool pending_;
|
bool pending_;
|
||||||
|
|
||||||
explicit ServiceClientBase(INode& node)
|
explicit ServiceClientBase(INode& node)
|
||||||
: DeadlineHandler(node.getScheduler())
|
: DeadlineHandler(node.getScheduler())
|
||||||
|
, data_type_descriptor_(NULL)
|
||||||
, request_timeout_(getDefaultRequestTimeout())
|
, request_timeout_(getDefaultRequestTimeout())
|
||||||
, pending_(false)
|
, pending_(false)
|
||||||
{ }
|
{ }
|
||||||
@@ -159,7 +162,7 @@ private:
|
|||||||
|
|
||||||
void invokeCallback(ServiceCallResultType& result);
|
void invokeCallback(ServiceCallResultType& result);
|
||||||
|
|
||||||
void handleReceivedDataStruct(ReceivedDataStructure<ResponseType>& response);
|
virtual void handleReceivedDataStruct(ReceivedDataStructure<ResponseType>& response);
|
||||||
|
|
||||||
virtual void handleDeadline(MonotonicTime);
|
virtual void handleDeadline(MonotonicTime);
|
||||||
|
|
||||||
|
|||||||
@@ -24,24 +24,30 @@ int ServiceClientBase::prepareToCall(INode& node, const char* dtname, NodeID ser
|
|||||||
/*
|
/*
|
||||||
* Determining the Data Type ID
|
* Determining the Data Type ID
|
||||||
*/
|
*/
|
||||||
GlobalDataTypeRegistry::instance().freeze();
|
if (data_type_descriptor_ == NULL)
|
||||||
const DataTypeDescriptor* const descr = GlobalDataTypeRegistry::instance().find(DataTypeKindService, dtname);
|
|
||||||
if (!descr)
|
|
||||||
{
|
{
|
||||||
UAVCAN_TRACE("ServiceClient", "Type [%s] is not registered", dtname);
|
GlobalDataTypeRegistry::instance().freeze();
|
||||||
return -ErrUnknownDataType;
|
data_type_descriptor_ = GlobalDataTypeRegistry::instance().find(DataTypeKindService, dtname);
|
||||||
|
if (data_type_descriptor_ == NULL)
|
||||||
|
{
|
||||||
|
UAVCAN_TRACE("ServiceClient", "Type [%s] is not registered", dtname);
|
||||||
|
return -ErrUnknownDataType;
|
||||||
|
}
|
||||||
|
UAVCAN_TRACE("ServiceClient", "Data type descriptor inited: %s", data_type_descriptor_->toString().c_str());
|
||||||
}
|
}
|
||||||
|
UAVCAN_ASSERT(data_type_descriptor_ != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determining the Transfer ID
|
* Determining the Transfer ID
|
||||||
*/
|
*/
|
||||||
const OutgoingTransferRegistryKey otr_key(descr->getID(), TransferTypeServiceRequest, server_node_id);
|
const OutgoingTransferRegistryKey otr_key(data_type_descriptor_->getID(),
|
||||||
|
TransferTypeServiceRequest, server_node_id);
|
||||||
const MonotonicTime otr_deadline = node.getMonotonicTime() + TransferSender::getDefaultMaxTransferInterval();
|
const MonotonicTime otr_deadline = node.getMonotonicTime() + TransferSender::getDefaultMaxTransferInterval();
|
||||||
TransferID* const otr_tid =
|
TransferID* const otr_tid =
|
||||||
node.getDispatcher().getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
|
node.getDispatcher().getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
|
||||||
if (!otr_tid)
|
if (!otr_tid)
|
||||||
{
|
{
|
||||||
UAVCAN_TRACE("ServiceClient", "OTR access failure, dtd=%s", descr->toString().c_str());
|
UAVCAN_TRACE("ServiceClient", "OTR access failure, dtd=%s", data_type_descriptor_->toString().c_str());
|
||||||
return -ErrMemory;
|
return -ErrMemory;
|
||||||
}
|
}
|
||||||
out_transfer_id = *otr_tid;
|
out_transfer_id = *otr_tid;
|
||||||
|
|||||||
Reference in New Issue
Block a user