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

[commands] Added some XCVR utilities

parent 009a0b01
......@@ -169,6 +169,18 @@ inline messages::XcvrAnalyse background_noise(SeatracDriver& seatrac, int64_t ti
return response;
}
inline messages::XcvrStatus xcvr_status(SeatracDriver& seatrac, int64_t timeout=1000)
{
messages::XcvrStatus response;
messages::XcvrStatus::Request request;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
}; //namespace command
}; //namespace seatrac
}; //namespace narval
......
......@@ -21,6 +21,8 @@
#include <seatrac_driver/messages/PingResp.h>
#include <seatrac_driver/messages/XcvrAnalyse.h>
#include <seatrac_driver/messages/XcvrStatus.h>
#include <seatrac_driver/messages/XcvrReceptionError.h>
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_MESSAGES_H_
......
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_XCVR_RECEPTION_ERROR_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_XCVR_RECEPTION_ERROR_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct XcvrReceptionError : public Message<XcvrReceptionError>
{
static const CID_E Identifier = CID_XCVR_RX_ERR;
XcvrReceptionError& operator=(const std::vector<uint8_t>& data)
{
if(data[0] != this->msgId) {
throw std::runtime_error("Wrong message for decoding.");
}
statusCode = (CST_E)data[1];
acousticFix.assign(data.size() - 2, data.data() + 2);
return *this;
}
CST_E statusCode;
ACOFIX_T acousticFix;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::XcvrReceptionError& msg)
{
using namespace narval::seatrac;
static const char* prefix = "\n- ";
os << "XcvrReceptionError : " << msg.statusCode
<< prefix << "acousticFix : " << print_utils::indent(msg.acousticFix);
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_XCVR_RECEPTION_ERROR_h_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_XCVR_STATUS_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_XCVR_STATUS_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct XcvrStatus : public Message<XcvrStatus>
{
using Message<XcvrStatus>::operator=;
static const CID_E Identifier = CID_XCVR_STATUS;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_XCVR_STATUS;
};
CST_E statusCode;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::XcvrStatus& msg)
{
os << "XcvrStatus : " << msg.statusCode;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_XCVR_STATUS_h_
......@@ -77,7 +77,8 @@ int main(int argc, char** argv)
//cout << command::settings_get(seatrac) << endl;
//cout << command::ping_send(seatrac, BEACON_ID_15) << endl;
//cout << command::ping_send(seatrac, BEACON_ID_15, MSG_REQU) << endl;
cout << command::background_noise(seatrac) << endl;
//cout << command::background_noise(seatrac) << endl;
cout << command::xcvr_status(seatrac) << endl;
}
catch(const TimeoutReached& e) {
cout << "Timeout reached" << endl;
......
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