5 #ifndef UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED
6 #define UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED
9 #include <uavcan/protocol/param/GetSet.hpp>
10 #include <uavcan/protocol/param/ExecuteOpcode.hpp>
27 typedef protocol::param::Value
Value;
35 virtual void getParamNameByIndex(Index index, Name& out_name)
const = 0;
40 virtual void assignParamValue(
const Name& name,
const Value& value) = 0;
45 virtual void readParamValue(
const Name& name, Value& out_value)
const = 0;
65 virtual int saveAllParams() = 0;
71 virtual int eraseAllParams() = 0;
84 void (
ParamServer::*)(
const protocol::param::ExecuteOpcode::Request&,
91 void handleGetSet(
const protocol::param::GetSet::Request& in, protocol::param::GetSet::Response& out)
99 UAVCAN_TRACE(
"ParamServer",
"GetSet: Index %i --> '%s'",
int(in.index), out.name.c_str());
106 if (out.name.empty())
108 UAVCAN_TRACE(
"ParamServer",
"GetSet: Can't resolve parameter name, index=%i",
int(in.index));
113 if (!in.value.is(protocol::param::Value::Tag::empty))
120 if (!out.value.is(protocol::param::Value::Tag::empty))
126 UAVCAN_TRACE(
"ParamServer",
"GetSet: Unknown param: index=%i name='%s'",
int(in.index), out.name.c_str());
132 protocol::param::ExecuteOpcode::Response& out)
136 if (in.opcode == protocol::param::ExecuteOpcode::Request::OPCODE_SAVE)
140 else if (in.opcode == protocol::param::ExecuteOpcode::Request::OPCODE_ERASE)
146 UAVCAN_TRACE(
"ParamServer",
"ExecuteOpcode: invalid opcode %i",
int(in.opcode));
154 , save_erase_srv_(
node)
166 return -ErrInvalidParam;
192 #endif // UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED