Using global RX object buffer

This commit is contained in:
Pavel Kirienko
2015-05-29 16:47:02 +03:00
parent d4e49d518a
commit d20f8e7356
7 changed files with 152 additions and 46 deletions
@@ -19,7 +19,8 @@ using uavcan::DefaultDataTypeRegistrator;
using uavcan::MonotonicDuration;
template <typename DataType>
static bool validateDataTypeInfoResponse(const std::auto_ptr<ServiceCallResult<GetDataTypeInfo> >& resp, unsigned mask)
static bool validateDataTypeInfoResponse(const std::auto_ptr<ServiceCallResultCollector<GetDataTypeInfo>::Result>& resp,
unsigned mask)
{
if (!resp.get())
{
+34 -5
View File
@@ -51,18 +51,47 @@ struct SubscriberWithCollector
template <typename DataType>
class ServiceCallResultCollector : uavcan::Noncopyable
{
typedef uavcan::ServiceCallResult<DataType> ResultType;
typedef uavcan::ServiceCallResult<DataType> ServiceCallResult;
void handler(const ResultType& result)
public:
class Result
{
this->result.reset(new ResultType(result));
const typename ServiceCallResult::Status status_;
uavcan::ServiceCallID call_id_;
typename DataType::Response response_;
public:
Result(typename ServiceCallResult::Status arg_status,
uavcan::ServiceCallID arg_call_id,
const typename DataType::Response& arg_response)
: status_(arg_status)
, call_id_(arg_call_id)
, response_(arg_response)
{ }
bool isSuccessful() const { return status_ == ServiceCallResult::Success; }
typename ServiceCallResult::Status getStatus() const { return status_; }
uavcan::ServiceCallID getCallID() const { return call_id_; }
const typename DataType::Response& getResponse() const { return response_; }
typename DataType::Response& getResponse() { return response_; }
};
private:
void handler(const uavcan::ServiceCallResult<DataType>& tmp_result)
{
std::cout << tmp_result << std::endl;
result.reset(new Result(tmp_result.getStatus(), tmp_result.getCallID(), tmp_result.getResponse()));
}
public:
std::auto_ptr<ResultType> result;
std::auto_ptr<Result> result;
typedef uavcan::MethodBinder<ServiceCallResultCollector*,
void (ServiceCallResultCollector::*)(const ResultType&)> Binder;
void (ServiceCallResultCollector::*)(const uavcan::ServiceCallResult<DataType>&)>
Binder;
Binder bind() { return Binder(this, &ServiceCallResultCollector::handler); }
};