From ddc4b649a89aaa8a501c5c16c71a73d6df3e77fd Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 18 Mar 2015 23:49:53 +0300 Subject: [PATCH] param.SaveErase --> param.ExecuteOpcode --- .../protocol/param/598.ExecuteOpcode.uavcan | 29 +++++++++++++++++++ .../protocol/param/598.SaveErase.uavcan | 17 ----------- .../include/uavcan/protocol/param_server.hpp | 13 +++++---- libuavcan/src/protocol/uc_param_server.cpp | 12 ++++---- libuavcan/test/protocol/param_server.cpp | 10 +++---- .../linux/apps/uavcan_nodetool.cpp | 14 ++++----- 6 files changed, 54 insertions(+), 41 deletions(-) create mode 100644 dsdl/uavcan/protocol/param/598.ExecuteOpcode.uavcan delete mode 100644 dsdl/uavcan/protocol/param/598.SaveErase.uavcan diff --git a/dsdl/uavcan/protocol/param/598.ExecuteOpcode.uavcan b/dsdl/uavcan/protocol/param/598.ExecuteOpcode.uavcan new file mode 100644 index 0000000000..626fb79c65 --- /dev/null +++ b/dsdl/uavcan/protocol/param/598.ExecuteOpcode.uavcan @@ -0,0 +1,29 @@ +# +# Service to control the node configuration. +# +# SAVE operation instructs the remote node to save the current configuration parameters to the non-volatile +# storage. The node may require a restart in order for some changes to take effect. +# +# ERASE operation instructs the remote node to clear its configuration storage and reinitialize the parameters +# with their default values. The node may require a restart in order for some changes to take effect. +# +# Other opcodes may be added in the future (for example, an opcode for switching between multiple configurations). +# + +uint8 OPCODE_SAVE = 0 # Save all parameters to non-volatile storage. +uint8 OPCODE_ERASE = 1 # Clear the non-volatile storage; some changes may take effect only after reboot. +uint8 opcode + +# +# Reserved, keep zero. +# +int48 argument + +--- + +# +# Reserved, keep zero. +# +int48 argument + +bool ok diff --git a/dsdl/uavcan/protocol/param/598.SaveErase.uavcan b/dsdl/uavcan/protocol/param/598.SaveErase.uavcan deleted file mode 100644 index 2f268283d1..0000000000 --- a/dsdl/uavcan/protocol/param/598.SaveErase.uavcan +++ /dev/null @@ -1,17 +0,0 @@ -# -# Service to control non-volatile parameter storage. -# -# SAVE operation instructs the remote node to save the current configuration parameters to the non-volatile -# storage. The device may require a restart in order for some changes to take effect. -# -# ERASE operation instructs the remote node to clear its configuration storage and reinitialize the parameters -# with their default values. The device may require a restart in order for some changes to take effect. -# - -uint8 OPCODE_SAVE = 0 # Save all parameters to non-volatile storage. -uint8 OPCODE_ERASE = 1 # Clear the non-volatile storage; some changes may take effect only after reboot. -uint8 opcode - ---- - -bool ok diff --git a/libuavcan/include/uavcan/protocol/param_server.hpp b/libuavcan/include/uavcan/protocol/param_server.hpp index f0292198a2..847095f430 100644 --- a/libuavcan/include/uavcan/protocol/param_server.hpp +++ b/libuavcan/include/uavcan/protocol/param_server.hpp @@ -6,7 +6,7 @@ #define UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED #include -#include +#include #include #include @@ -75,19 +75,20 @@ class UAVCAN_EXPORT ParamServer typedef MethodBinder GetSetCallback; - typedef MethodBinder SaveEraseCallback; + typedef MethodBinder ExecuteOpcodeCallback; ServiceServer get_set_srv_; - ServiceServer save_erase_srv_; + ServiceServer save_erase_srv_; IParamManager* manager_; static bool isValueNonEmpty(const protocol::param::Value& value); void handleGetSet(const protocol::param::GetSet::Request& request, protocol::param::GetSet::Response& response); - void handleSaveErase(const protocol::param::SaveErase::Request& request, - protocol::param::SaveErase::Response& response); + void handleExecuteOpcode(const protocol::param::ExecuteOpcode::Request& request, + protocol::param::ExecuteOpcode::Response& response); public: explicit ParamServer(INode& node) diff --git a/libuavcan/src/protocol/uc_param_server.cpp b/libuavcan/src/protocol/uc_param_server.cpp index 0096239fa0..164ac1316e 100644 --- a/libuavcan/src/protocol/uc_param_server.cpp +++ b/libuavcan/src/protocol/uc_param_server.cpp @@ -49,22 +49,22 @@ void ParamServer::handleGetSet(const protocol::param::GetSet::Request& in, proto } } -void ParamServer::handleSaveErase(const protocol::param::SaveErase::Request& in, - protocol::param::SaveErase::Response& out) +void ParamServer::handleExecuteOpcode(const protocol::param::ExecuteOpcode::Request& in, + protocol::param::ExecuteOpcode::Response& out) { UAVCAN_ASSERT(manager_ != NULL); - if (in.opcode == protocol::param::SaveErase::Request::OPCODE_SAVE) + if (in.opcode == protocol::param::ExecuteOpcode::Request::OPCODE_SAVE) { out.ok = manager_->saveAllParams() >= 0; } - else if (in.opcode == protocol::param::SaveErase::Request::OPCODE_ERASE) + else if (in.opcode == protocol::param::ExecuteOpcode::Request::OPCODE_ERASE) { out.ok = manager_->eraseAllParams() >= 0; } else { - UAVCAN_TRACE("ParamServer", "SaveErase: invalid opcode %i", int(in.opcode)); + UAVCAN_TRACE("ParamServer", "ExecuteOpcode: invalid opcode %i", int(in.opcode)); out.ok = false; } } @@ -83,7 +83,7 @@ int ParamServer::start(IParamManager* manager) return res; } - res = save_erase_srv_.start(SaveEraseCallback(this, &ParamServer::handleSaveErase)); + res = save_erase_srv_.start(ExecuteOpcodeCallback(this, &ParamServer::handleExecuteOpcode)); if (res < 0) { get_set_srv_.stop(); diff --git a/libuavcan/test/protocol/param_server.cpp b/libuavcan/test/protocol/param_server.cpp index dd65bb5c9e..c7a27a0f8e 100644 --- a/libuavcan/test/protocol/param_server.cpp +++ b/libuavcan/test/protocol/param_server.cpp @@ -93,23 +93,23 @@ TEST(ParamServer, Basic) uavcan::GlobalDataTypeRegistry::instance().reset(); uavcan::DefaultDataTypeRegistrator _reg1; - uavcan::DefaultDataTypeRegistrator _reg2; + uavcan::DefaultDataTypeRegistrator _reg2; ASSERT_LE(0, server.start(&mgr)); ServiceClientWithCollector get_set_cln(nodes.b); - ServiceClientWithCollector save_erase_cln(nodes.b); + ServiceClientWithCollector save_erase_cln(nodes.b); /* * Save/erase */ - uavcan::protocol::param::SaveErase::Request save_erase_rq; - save_erase_rq.opcode = uavcan::protocol::param::SaveErase::Request::OPCODE_SAVE; + uavcan::protocol::param::ExecuteOpcode::Request save_erase_rq; + save_erase_rq.opcode = uavcan::protocol::param::ExecuteOpcode::Request::OPCODE_SAVE; doCall(save_erase_cln, save_erase_rq, nodes); ASSERT_TRUE(save_erase_cln.collector.result.get()); ASSERT_TRUE(save_erase_cln.collector.result->response.ok); - save_erase_rq.opcode = uavcan::protocol::param::SaveErase::Request::OPCODE_ERASE; + save_erase_rq.opcode = uavcan::protocol::param::ExecuteOpcode::Request::OPCODE_ERASE; doCall(save_erase_cln, save_erase_rq, nodes); ASSERT_TRUE(save_erase_cln.collector.result->response.ok); diff --git a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp index 822144701b..f580f39f6a 100644 --- a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp @@ -14,7 +14,7 @@ #include "debug.hpp" #include -#include +#include #include #include @@ -185,11 +185,11 @@ const std::map&) { - auto client = node->makeBlockingServiceClient(); - uavcan::protocol::param::SaveErase::Request request; + auto client = node->makeBlockingServiceClient(); + uavcan::protocol::param::ExecuteOpcode::Request request; request.opcode = request.OPCODE_SAVE; std::cout << call(*client, node_id, request) << std::endl; } @@ -198,11 +198,11 @@ const std::map&) { - auto client = node->makeBlockingServiceClient(); - uavcan::protocol::param::SaveErase::Request request; + auto client = node->makeBlockingServiceClient(); + uavcan::protocol::param::ExecuteOpcode::Request request; request.opcode = request.OPCODE_ERASE; std::cout << call(*client, node_id, request) << std::endl; }