mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 07:43:34 +08:00
Stack-allocating the service response structure
This commit is contained in:
@@ -120,26 +120,26 @@ private:
|
||||
PublisherType publisher_;
|
||||
Callback callback_;
|
||||
uint32_t response_failure_count_;
|
||||
ServiceResponseDataStructure<ResponseType> response_;
|
||||
|
||||
virtual void handleReceivedDataStruct(ReceivedDataStructure<RequestType>& request)
|
||||
{
|
||||
UAVCAN_ASSERT(request.getTransferType() == TransferTypeServiceRequest);
|
||||
|
||||
ServiceResponseDataStructure<ResponseType> response;
|
||||
|
||||
if (try_implicit_cast<bool>(callback_, true))
|
||||
{
|
||||
// The application needs newly initialized structure
|
||||
response_ = ServiceResponseDataStructure<ResponseType>();
|
||||
UAVCAN_ASSERT(response_.isResponseEnabled()); // Enabled by default
|
||||
callback_(request, response_);
|
||||
UAVCAN_ASSERT(response.isResponseEnabled()); // Enabled by default
|
||||
callback_(request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
handleFatalError("Srv serv clbk");
|
||||
}
|
||||
|
||||
if (response_.isResponseEnabled())
|
||||
if (response.isResponseEnabled())
|
||||
{
|
||||
const int res = publisher_.publish(response_, TransferTypeServiceResponse, request.getSrcNodeID(),
|
||||
const int res = publisher_.publish(response, TransferTypeServiceResponse, request.getSrcNodeID(),
|
||||
request.getTransferID());
|
||||
if (res < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user