Commit 009a0b01 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[commands] Added XcvrAnalyse (background noise analysis)

parent 26bf0112
......@@ -157,6 +157,18 @@ inline messages::PingSend ping_send(SeatracDriver& seatrac,
return response;
}
inline messages::XcvrAnalyse background_noise(SeatracDriver& seatrac, int64_t timeout=1000)
{
messages::XcvrAnalyse response;
messages::XcvrAnalyse::Request request;
if(!seatrac.send_request(sizeof(request), (const uint8_t*)&request, &response, timeout)) {
throw TimeoutReached();
}
return response;
}
}; //namespace command
}; //namespace seatrac
}; //namespace narval
......
......@@ -20,6 +20,8 @@
#include <seatrac_driver/messages/PingReq.h>
#include <seatrac_driver/messages/PingResp.h>
#include <seatrac_driver/messages/XcvrAnalyse.h>
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_MESSAGES_H_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_XCVR_ANALYSE_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_XCVR_ANALYSE_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct XcvrAnalyse : public Message<XcvrAnalyse>
{
using Message<XcvrAnalyse>::operator=;
static const CID_E Identifier = CID_XCVR_ANALYSE;
struct Request : public Message<Request> {
static const CID_E Identifier = CID_XCVR_ANALYSE;
};
CST_E statusCode;
int16_t adcMean;
uint16_t adcPkPk;
uint32_t adcRMS;
int16_t rxLevelPkPk;
int16_t rxLevelRMS;
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::XcvrAnalyse& msg)
{
using namespace narval::seatrac;
static const char* prefix = "\n- ";
os << "XcvrAnalyse :"
<< prefix << "statusCode : " << msg.statusCode
<< prefix << "adcMean : " << msg.adcMean
<< prefix << "adcPkPk : " << msg.adcPkPk
<< prefix << "adcRMS : " << msg.adcRMS
<< prefix << "rxLevelPkPk : " << msg.rxLevelPkPk
<< prefix << "rxLevelRMS : " << msg.rxLevelRMS;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_XCVR_ANALYSE_h_
......@@ -35,9 +35,6 @@ void SeatracDriver::on_receive(const std::vector<uint8_t>& data)
default:
std::cout << "Got message : " << msgId << std::endl << std::flush;
break;
case CID_PING_REQ:
std::cout << "Got a Ping Request" << std::endl << std::flush;
break;
case CID_PING_RESP:
// std::cout << "Got a Ping Response" << std::endl << std::flush;
{
......@@ -49,7 +46,6 @@ void SeatracDriver::on_receive(const std::vector<uint8_t>& data)
case CID_STATUS:
break;
}
// std::cout << "Received : " << data.size() << " bytes." << std::endl;
}
}; //namespace seatrac
......
......@@ -76,7 +76,8 @@ int main(int argc, char** argv)
//cout << command::status_config_get(seatrac) << endl;
//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::ping_send(seatrac, BEACON_ID_15, MSG_REQU) << endl;
cout << command::background_noise(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