Commit 60c1f83e authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[driver] Added some print function and Fixed a specification error

parent 8d97e5f2
......@@ -3,6 +3,7 @@
#include <cstdint>
#include <iostream>
#include <sstream>
namespace narval { namespace seatrac {
......@@ -612,6 +613,61 @@ enum XCVR_FLAGS_E : uint8_t {
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::BAUDRATE_E rate)
{
using namespace narval::seatrac;
switch(rate) {
case BAUD_4800 : os << "BAUD_4800"; break;
case BAUD_9600 : os << "BAUD_9600"; break;
case BAUD_14400 : os << "BAUD_14400"; break;
case BAUD_19200 : os << "BAUD_19200"; break;
case BAUD_38400 : os << "BAUD_38400"; break;
case BAUD_57600 : os << "BAUD_57600"; break;
case BAUD_115200 : os << "BAUD_115200"; break;
default: os << "Unknown Baudrate";
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::ENV_FLAGS_E flags)
{
std::ostringstream oss;
if(flags & narval::seatrac::AUTO_VOS) oss << " | AUTO_VOS";
if(flags & narval::seatrac::AUTO_PRESSURE_OFS) oss << " | AUTO_PRESSURE_OFS";
if(oss.str().size() > 2)
os << oss.str().substr(3);
else
os << "None";
return os;
}
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::AHRS_FLAGS_E flags)
{
if(flags & narval::seatrac::AUTO_CAL_MAG)
os << "AUTO_CAL_MAG enabled";
else
os << "AUTO_CAL_MAG disabled";
return os;
}
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::XCVR_FLAGS_E flags)
{
std::ostringstream oss;
if(flags & narval::seatrac::USBL_USE_AHRS) oss << " | USBL_USE_AHRS";
if(flags & narval::seatrac::XCVR_POSFLT_ENABLE) oss << " | XCVR_POSFLT_ENABLE";
if(flags & narval::seatrac::XCVR_USBL_MSGS) oss << " | XCVR_USBL_MSGS";
if(flags & narval::seatrac::XCVR_FIX_MSGS) oss << " | XCVR_FIX_MSGS";
if(flags & narval::seatrac::XCVR_DIAG_MSGS) oss << " | XCVR_DIAG_MSGS";
if(oss.str().size() > 2)
os << oss.str().substr(3);
else
os << "None";
return os;
}
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::CID_E cid)
{
using namespace narval::seatrac;
......
......@@ -411,7 +411,9 @@ struct SETTINGS_T {
ENV_FLAGS_E envFlags; // This value contains flags that control the
// processing of the beacons environmental sensors
// (pressure, temperature, supply voltage etc).
int32_t envPressureOfs; // The manually specified offset applied to readings
// int32_t envPressureOfs; // Specification says 32bits but they are
// probably liars (full decoding ok with 16bits).
int16_t envPressureOfs; // The manually specified offset applied to readings
// take from the pressure sensor to compensate for
// altitude and atmospheric pressure changes.
// Values are encoded in milli-Bars, so divide by
......@@ -583,4 +585,86 @@ inline std::ostream& operator<<(std::ostream& os,
return os;
}
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::IPADDR_T ip)
{
os << ip.bytes[3]
<< "." << ip.bytes[2]
<< "." << ip.bytes[1]
<< "." << ip.bytes[0];
return os;
}
inline std::ostream& operator<<(std::ostream& os, narval::seatrac::MACADDR_T mac)
{
os << mac.bytes[5]
<< ":" << mac.bytes[4]
<< ":" << mac.bytes[3]
<< ":" << mac.bytes[2]
<< ":" << mac.bytes[1]
<< ":" << mac.bytes[0];
return os;
}
inline std::ostream& operator<<(std::ostream& os, const narval::seatrac::AHRSCAL_T& cal)
{
static const char* prefix = "\n- ";
os << "AHRS Calibration data :"
<< prefix << "accMinX : " << cal.accMinX
<< prefix << "accMinY : " << cal.accMinY
<< prefix << "accMinZ : " << cal.accMinZ
<< prefix << "accMaxX : " << cal.accMaxX
<< prefix << "accMaxY : " << cal.accMaxY
<< prefix << "accMaxZ : " << cal.accMaxZ
<< prefix << "magValid : " << cal.magValid
<< prefix << "magHardX : " << cal.magHardX
<< prefix << "magHardY : " << cal.magHardY
<< prefix << "magHardZ : " << cal.magHardZ
<< prefix << "magSoftX : " << cal.magSoftX
<< prefix << "magSoftY : " << cal.magSoftY
<< prefix << "magSoftZ : " << cal.magSoftZ
<< prefix << "magField : " << cal.magField
<< prefix << "magError : " << cal.magError
<< prefix << "gyroOffsetX : " << cal.gyroOffsetX
<< prefix << "gyroOffsetY : " << cal.gyroOffsetY
<< prefix << "gyroOffsetZ : " << cal.gyroOffsetZ;
return os;
}
inline std::ostream& operator<<(std::ostream& os, const narval::seatrac::SETTINGS_T& settings)
{
using namespace narval::seatrac::print_utils;
static const char* prefix = "\n- ";
os << "Settings :"
<< prefix << "statusFlags : " << settings.statusFlags
<< prefix << "status_output : " << settings.status_output
<< prefix << "uartMainBaud : " << settings.uartMainBaud
<< prefix << "uartAuxBaud : " << settings.uartAuxBaud
<< prefix << "netMacAddr : " << settings.netMacAddr
<< prefix << "netIpAddr : " << settings.netIpAddr
<< prefix << "netIpSubnet : " << settings.netIpSubnet
<< prefix << "netIpGateway : " << settings.netIpGateway
<< prefix << "netIpDns : " << settings.netIpDns
<< prefix << "netTcpPort : " << settings.netTcpPort
<< prefix << "envFlags : " << settings.envFlags
<< prefix << "envPressureOfs : " << settings.envPressureOfs
<< prefix << "envSalinity : " << settings.envSalinity
<< prefix << "envVos : " << settings.envVos
<< prefix << "ahrsFlags : " << settings.ahrsFlags
<< prefix << "ahrsCal : " << indent(settings.ahrsCal)
<< prefix << "ahrsYawOfs : " << settings.ahrsYawOfs
<< prefix << "ahrsPitchOfs : " << settings.ahrsPitchOfs
<< prefix << "ahrsRollOfs : " << settings.ahrsRollOfs
<< prefix << "xcvrFlags : " << settings.xcvrFlags
<< prefix << "xcvrBeaconId : " << settings.xcvrBeaconId
<< prefix << "xcvrRangeTmo : " << settings.xcvrRangeTmo
<< prefix << "xcvrRespTime : " << settings.xcvrRespTime
<< prefix << "xcvrYaw : " << settings.xcvrYaw
<< prefix << "xcvrPitch : " << settings.xcvrPitch
<< prefix << "xcvrRoll : " << settings.xcvrRoll
<< prefix << "xcvrPosfltVel : " << (int)settings.xcvrPosfltVel
<< prefix << "xcvrPosfltAng : " << (int)settings.xcvrPosfltAng
<< prefix << "xcvrPosfltTmo : " << (int)settings.xcvrPosfltTmo;
return os;
}
#endif //_DEF_SEATRAC_DRIVER_SEATRAC_TYPES_H_
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