Commit 9517f875 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[commands] Added PingSend command

parent c5777a2c
......@@ -28,6 +28,8 @@ list(APPEND seatrac_driver_headers
include/seatrac_driver/messages/SettingsGet.h
include/seatrac_driver/messages/SettingsSet.h
include/seatrac_driver/messages/PingSend.h
)
add_library(seatrac_driver SHARED
......
......@@ -103,6 +103,24 @@ inline messages::SettingsSet settings_set(SeatracDriver& seatrac,
return response;
}
inline messages::PingSend ping_send(SeatracDriver& seatrac,
BID_E target,
AMSGTYPE_E pingType = MSG_REQ, // MSG_REQ simple ping without USBL info
int64_t timeout=1000)
{
messages::PingSend response;
messages::PingSend::Request request;
request.target = target;
request.pingType = pingType;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
}; //namespace command
}; //namespace seatrac
}; //namespace narval
......
......@@ -13,6 +13,8 @@
#include <seatrac_driver/messages/SettingsGet.h>
#include <seatrac_driver/messages/SettingsSet.h>
#include <seatrac_driver/messages/PingSend.h>
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_MESSAGES_H_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_PING_SEND_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_PING_SEND_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct PingSend : public Message<PingSend>
{
using Message<PingSend>::operator=;
static const CID_E Identifier = CID_PING_SEND;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_PING_SEND;
BID_E target;
AMSGTYPE_E pingType;
};
CST_E statusCode;
BID_E target;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::PingSend& msg)
{
os << "PingSend : " << msg.statusCode << ", target : " << msg.target;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_PING_SEND_H_
......@@ -39,29 +39,29 @@ int main(int argc, char** argv)
// STATUS_MODE_1HZ
//) << endl;
auto settings = command::settings_get(seatrac).settings;
cout << "Current settings : " << settings << endl;
cout << "Type enter to change settings" << endl;
// // changing beacon id to 1
// auto settings = command::settings_get(seatrac).settings;
// cout << "Current settings : " << settings << endl;
// cout << "Type enter to change settings" << endl;
// getchar();
// settings.xcvrBeaconId = BEACON_ID_1;
// cout << command::settings_set(seatrac, settings) << endl;
// settings = command::settings_get(seatrac).settings;
// cout << "New settings : " << settings << endl;
// changing beacon id
settings.xcvrBeaconId = BEACON_ID_1;
cout << command::settings_set(seatrac, settings) << 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++) {
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;
cout << command::ping_send(seatrac, BEACON_ID_15) << endl;
}
catch(const TimeoutReached& e) {
cout << "Timeout reached" << endl;
}
}
// for(int i = 0; i < 100; i++) {
// 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