Commit 99361f9a authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[messages] Added StatusConfigGet

parent c4b35c47
......@@ -14,12 +14,16 @@ list(APPEND seatrac_driver_headers
include/seatrac_driver/SeatracDriver.h
include/seatrac_driver/DataWaiter.h
include/seatrac_driver/commands.h
include/seatrac_driver/messages/MessageBase.h
include/seatrac_driver/messages/Messages.h
include/seatrac_driver/messages/Status.h
include/seatrac_driver/commands.h
include/seatrac_driver/messages/SysAlive.h
include/seatrac_driver/messages/SysInfo.h
include/seatrac_driver/messages/SysReboot.h
include/seatrac_driver/messages/Status.h
include/seatrac_driver/messages/StatusConfigGet.h
)
add_library(seatrac_driver SHARED
......
......@@ -42,6 +42,18 @@ inline messages::SysReboot sys_reboot(SeatracDriver& seatrac, int64_t timeout=10
return response;
}
inline messages::StatusConfigGet status_config_get(SeatracDriver& seatrac, int64_t timeout=1000)
{
messages::StatusConfigGet response;
messages::StatusConfigGet::Request request;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
}; //namespace command
}; //namespace seatrac
}; //namespace narval
......
......@@ -7,6 +7,7 @@
#include <seatrac_driver/messages/SysReboot.h>
#include <seatrac_driver/messages/Status.h>
#include <seatrac_driver/messages/StatusConfigGet.h>
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_MESSAGES_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 StatusConfigGet : public Message<StatusConfigGet>
{
using Message<StatusConfigGet>::operator=;
static const CID_E Identifier = CID_STATUS_CFG_GET;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_STATUS_CFG_GET;
};
STATUS_BITS_E statusOutput;
STATUSMODE_E statusMode;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::StatusConfigGet& msg)
{
using namespace narval::seatrac;
static const char* prefix = "\n- ";
os << "StatusConfigGet :"
<< prefix << "statusOutput : " << print_utils::indent(msg.statusOutput)
<< prefix << "statusMode : " << msg.statusMode;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_SYSAlive_H_
......@@ -20,30 +20,36 @@ narval::seatrac::messages::Status get_next_status(SeatracDriver& seatrac)
int main()
{
AsyncService service;
SeatracDriver seatrac(service.io_service(), "/dev/ttyUSB0");
SeatracDriver seatrac(service.io_service(), "/dev/narval_usbl");
seatrac.enable_io_dump();
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;
for(int i = 0; i < 1000; i++) {
//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 << get_next_status(seatrac) << endl;
//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 << 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