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

[command/messages] Added SettingsSet command

parent e6ed99d1
......@@ -25,6 +25,9 @@ list(APPEND seatrac_driver_headers
include/seatrac_driver/messages/Status.h
include/seatrac_driver/messages/StatusConfigGet.h
include/seatrac_driver/messages/StatusConfigSet.h
include/seatrac_driver/messages/SettingsGet.h
include/seatrac_driver/messages/SettingsSet.h
)
add_library(seatrac_driver SHARED
......
......@@ -728,7 +728,7 @@ inline std::ostream& operator<<(std::ostream& os, narval::seatrac::CID_E cid)
return os;
}
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::CST_E& statusCode)
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::CST_E statusCode)
{
using namespace narval::seatrac;
switch(statusCode) {
......
......@@ -87,7 +87,21 @@ inline messages::SettingsGet settings_get(SeatracDriver& seatrac, int64_t timeou
return response;
}
inline messages::SettingsSet settings_set(SeatracDriver& seatrac,
SETTINGS_T settings,
int64_t timeout=1000)
{
messages::SettingsSet response;
messages::SettingsSet::Request request;
request.settings = settings;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
}; //namespace command
}; //namespace seatrac
......
......@@ -11,6 +11,7 @@
#include <seatrac_driver/messages/StatusConfigSet.h>
#include <seatrac_driver/messages/SettingsGet.h>
#include <seatrac_driver/messages/SettingsSet.h>
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_MESSAGES_H_
......
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_SET_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_SET_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct SettingsSet : public Message<SettingsSet>
{
using Message<SettingsSet>::operator=;
static const CID_E Identifier = CID_SETTINGS_SET;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_SETTINGS_SET;
SETTINGS_T settings;
};
CST_E statusCode;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::SettingsSet& msg)
{
os << "SettingsSet : " << msg.statusCode;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_SETTINGS_SET_H_
......@@ -39,27 +39,38 @@ int main(int argc, char** argv)
// STATUS_MODE_1HZ
//) << endl;
for(int i = 0; i < 10; i++) {
getchar();
try {
//cout << command::sys_alive(seatrac) << endl;
//cout << command::sys_info(seatrac) << endl;
//cout << command::status_config_get(seatrac) << endl;
cout << command::settings_get(seatrac) << endl;
}
catch(const TimeoutReached& e) {
cout << "Timeout reached" << endl;
}
}
auto settings = command::settings_get(seatrac).settings;
cout << "Current settings : " << settings << endl;
cout << "Type enter to change settings" << endl;
// changing beacon id
settings.xcvrBeaconId = BEACON_ID_1;
cout << command::settings_set(seatrac, settings) << endl;
for(int i = 0; i < 100; i++) {
try {
cout << get_next_status(seatrac) << endl;
}
catch(const TimeoutReached& e) {
cout << "Timeout reached" << endl;
}
}
settings = command::settings_get(seatrac).settings;
cout << "New settings : " << settings << endl;
// for(int i = 0; i < 10; i++) {
// getchar();
// try {
// //cout << command::sys_alive(seatrac) << endl;
// //cout << command::sys_info(seatrac) << endl;
// //cout << command::status_config_get(seatrac) << endl;
// cout << command::settings_get(seatrac) << endl;
// }
// catch(const TimeoutReached& e) {
// cout << "Timeout reached" << endl;
// }
// }
// for(int i = 0; i < 100; i++) {
// try {
// cout << get_next_status(seatrac) << endl;
// }
// catch(const TimeoutReached& e) {
// cout << "Timeout reached" << endl;
// }
// }
service.stop();
......
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