Commit 126d6710 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[driver] Added StatusConfigSet command

parent 4c39cef3
......@@ -24,6 +24,7 @@ list(APPEND seatrac_driver_headers
include/seatrac_driver/messages/Status.h
include/seatrac_driver/messages/StatusConfigGet.h
include/seatrac_driver/messages/StatusConfigSet.h
)
add_library(seatrac_driver SHARED
......
......@@ -54,6 +54,27 @@ inline messages::StatusConfigGet status_config_get(SeatracDriver& seatrac, int64
return response;
}
inline messages::StatusConfigSet status_config_set(SeatracDriver& seatrac,
STATUS_BITS_E statusOutput = ENVIRONMENT | ATTITUDE | MAG_CAL | ACC_CAL | AHRS_RAW_DATA,
STATUSMODE_E statusMode = STATUS_MODE_10HZ,
int64_t timeout=1000)
{
messages::StatusConfigSet response;
messages::StatusConfigSet::Request request;
std::cout << "Filling parameters" << std::endl << std::flush;
request.statusOutput = statusOutput;
request.statusMode = statusMode;
std::cout << "send request" << std::endl << std::flush;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
std::cout << "Got result" << std::endl << std::flush;
return response;
}
}; //namespace command
}; //namespace seatrac
}; //namespace narval
......
......@@ -8,6 +8,7 @@
#include <seatrac_driver/messages/Status.h>
#include <seatrac_driver/messages/StatusConfigGet.h>
#include <seatrac_driver/messages/StatusConfigSet.h>
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_MESSAGES_H_
......
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGSET_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGSET_H_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGGET_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGGET_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
......@@ -36,5 +36,5 @@ inline std::ostream& operator<<(std::ostream& os,
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_SYSAlive_H_
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGGET_H_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGSET_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGSET_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct StatusConfigSet : public Message<StatusConfigSet>
{
using Message<StatusConfigSet>::operator=;
static const CID_E Identifier = CID_STATUS_CFG_SET;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_STATUS_CFG_SET;
STATUS_BITS_E statusOutput;
STATUSMODE_E statusMode;
};
CST_E statusCode;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::StatusConfigSet& msg)
{
static const char* prefix = "\n- ";
os << "StatusConfigSet : " << msg.statusCode;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_STATUSCONFIGSET_H_
......@@ -25,31 +25,38 @@ int main()
service.start();
// cout << "Type Enter for reboot" << endl;
// getchar();
// cout << command::sys_reboot(seatrac) << endl;
//cout << "Type Enter for reboot" << endl;
//getchar();
//cout << command::sys_reboot(seatrac) << endl;
//cout << "Type enter to configure status message" << endl;
//getchar();
//cout << command::status_config_set(seatrac,
// ENVIRONMENT | ATTITUDE | MAG_CAL | ACC_CAL | AHRS_RAW_DATA | AHRS_COMP_DATA,
// STATUS_MODE_1HZ
//) << endl;
for(int i = 0; i < 10; i++) {
getchar();
//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;
// }
// catch(const TimeoutReached& e) {
// cout << "Timeout reached" << endl;
// }
//}
for(int i = 0; i < 100; i++) {
try {
//cout << command::sys_alive(seatrac) << endl;
//cout << command::sys_info(seatrac) << endl;
//cout << command::status_config_get(seatrac) << endl;
cout << get_next_status(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();
return 0;
......
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