Commit e6789c18 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[commands] Added Settings/Load/Save/Reset

parent f2b08ef3
......@@ -103,6 +103,42 @@ inline messages::SettingsSet settings_set(SeatracDriver& seatrac,
return response;
}
inline messages::SettingsLoad settings_load(SeatracDriver& seatrac, int64_t timeout=1000)
{
messages::SettingsLoad response;
messages::SettingsLoad::Request request;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
inline messages::SettingsSave settings_save(SeatracDriver& seatrac, int64_t timeout=1000)
{
messages::SettingsSave response;
messages::SettingsSave::Request request;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
inline messages::SettingsReset settings_reset(SeatracDriver& seatrac, int64_t timeout=1000)
{
messages::SettingsReset response;
messages::SettingsReset::Request request;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
inline messages::PingSend ping_send(SeatracDriver& seatrac,
BID_E target,
AMSGTYPE_E pingType = MSG_REQ, // MSG_REQ simple ping without USBL info
......
......@@ -12,6 +12,9 @@
#include <seatrac_driver/messages/SettingsGet.h>
#include <seatrac_driver/messages/SettingsSet.h>
#include <seatrac_driver/messages/SettingsLoad.h>
#include <seatrac_driver/messages/SettingsSave.h>
#include <seatrac_driver/messages/SettingsReset.h>
#include <seatrac_driver/messages/PingSend.h>
#include <seatrac_driver/messages/PingReq.h>
......
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_LOAD_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_LOAD_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct SettingsLoad : public Message<SettingsLoad>
{
using Message<SettingsLoad>::operator=;
static const CID_E Identifier = CID_SETTINGS_LOAD;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_SETTINGS_LOAD;
};
CST_E statusCode;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::SettingsLoad& msg)
{
os << "SettingsLoad : " << msg.statusCode;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_LOAD_H_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_RESET_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_RESET_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct SettingsReset : public Message<SettingsReset>
{
using Message<SettingsReset>::operator=;
static const CID_E Identifier = CID_SETTINGS_RESET;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_SETTINGS_RESET;
};
CST_E statusCode;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::SettingsReset& msg)
{
os << "SettingsReset : " << msg.statusCode;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_RESET_H_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_SAVE_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_SAVE_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct SettingsSave : public Message<SettingsSave>
{
using Message<SettingsSave>::operator=;
static const CID_E Identifier = CID_SETTINGS_SAVE;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_SETTINGS_SAVE;
};
CST_E statusCode;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::SettingsSave& msg)
{
os << "SettingsSave : " << msg.statusCode;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_SAVE_H_
......@@ -48,7 +48,26 @@ int main(int argc, char** argv)
// cout << command::settings_set(seatrac, settings) << endl;
// settings = command::settings_get(seatrac).settings;
// cout << "New settings : " << settings << endl;
// cout << "Type enter to save settings" << endl;
// getchar();
// cout << command::settings_save(seatrac) << endl;
// settings = command::settings_get(seatrac).settings;
// cout << "New settings : " << settings << endl;
// // reloading saved settings
// cout << "Type enter to reload settings" << endl;
// getchar();
// cout << command::settings_load(seatrac) << endl;
// settings = command::settings_get(seatrac).settings;
// cout << "New settings : " << settings << endl;
// // factory reset settings
// cout << "Type enter to reset settings" << endl;
// getchar();
// cout << command::settings_reset(seatrac) << endl;
// cout << "New settings : " << command::settings_get(seatrac).settings << endl;
for(int i = 0; i < 100; i++) {
getchar();
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment