DESERT 4.0.0
UwInterpreterAhoi Class Reference

#include <uwinterpreterahoi.h>

Collaboration diagram for UwInterpreterAhoi:
Collaboration graph

Public Member Functions

 UwInterpreterAhoi (int id)
 
 ~UwInterpreterAhoi ()
 
std::string serializePacket (ahoi::packet_t *packet)
 
std::string buildSend (ahoi::packet_t pck)
 
std::string buildID (int id)
 
std::string buildBatVol ()
 
std::string buildReset ()
 
std::string buildRange ()
 
std::string buildAgc ()
 
std::string buildRangeDelay ()
 
std::string buildDistance ()
 
std::string buildRxGain ()
 
std::string buildTxGain ()
 
std::string buildPacketStat ()
 
std::string buildPacketStatReset ()
 
std::string buildSyncStat ()
 
std::string buildSyncStatReset ()
 
std::string buildSfdStat ()
 
std::string buildSfdStatReset ()
 
std::string buildAllStat ()
 
std::string buildAllStatReset ()
 
std::string findResponse (std::vector< char >::iterator beg, std::vector< char >::iterator end, std::vector< char >::iterator &rsp_beg, std::vector< char >::iterator &rsp_end)
 
void fixEscapes (std::vector< char > &buffer, std::vector< char >::iterator &c_beg, std::vector< char >::iterator &c_end)
 
std::shared_ptr< ahoi::packet_t > parseResponse (std::vector< char >::iterator c_beg, std::vector< char >::iterator c_end)
 

Private Attributes

uint8_t id
 
uint8_t sn
 
std::array< uint8_t, 2 > beg_del
 
std::array< uint8_t, 2 > end_del
 

Static Private Attributes

static uint header_size = 6
 
static uint footer_size = 6
 
static const uint8_t dle = 0x10
 
static const uint8_t stx = 0x02
 
static const uint8_t etx = 0x03
 

Detailed Description

Class used for building syntactically compliant commands to send to the ahoi! modems and interpreting the responses from ahoi! modems. For doubts and requests please refer to: https://www.tuhh.de/smartport/research/acoustic-modem.html

Constructor & Destructor Documentation

◆ UwInterpreterAhoi()

UwInterpreterAhoi::UwInterpreterAhoi ( int  id)

Constructor of the interpreter class.

Parameters
idinteger identifier of the modem

References beg_del, dle, end_del, etx, and stx.

◆ ~UwInterpreterAhoi()

UwInterpreterAhoi::~UwInterpreterAhoi ( )

Destructor of the interpreter class

Member Function Documentation

◆ buildAgc()

std::string UwInterpreterAhoi::buildAgc ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::agc, ahoi::commands_id, id, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildAllStat()

std::string UwInterpreterAhoi::buildAllStat ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::allstat, ahoi::commands_id, id, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildAllStatReset()

std::string UwInterpreterAhoi::buildAllStatReset ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::allstatreset, ahoi::commands_id, id, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildBatVol()

std::string UwInterpreterAhoi::buildBatVol ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::batvol, ahoi::commands_id, id, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildDistance()

std::string UwInterpreterAhoi::buildDistance ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, ahoi::distance, id, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildID()

std::string UwInterpreterAhoi::buildID ( int  id)

Method that builds the command to ask the modem its own ID number

Parameters
idinteger identifier to set: if 0, ask for id
Returns
string containing the symbols of the command

References ahoi::commands_id, ahoi::id, id, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildPacketStat()

std::string UwInterpreterAhoi::buildPacketStat ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, ahoi::packetstat, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildPacketStatReset()

std::string UwInterpreterAhoi::buildPacketStatReset ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, ahoi::packetstatreset, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildRange()

std::string UwInterpreterAhoi::buildRange ( )

Method that builds the command

Returns
string containing the symbols of the command

◆ buildRangeDelay()

std::string UwInterpreterAhoi::buildRangeDelay ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, ahoi::range_delay, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildReset()

std::string UwInterpreterAhoi::buildReset ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, ahoi::reset, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildRxGain()

std::string UwInterpreterAhoi::buildRxGain ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, ahoi::rxgain, serializePacket(), and sn.

Here is the call graph for this function:

◆ buildSend()

std::string UwInterpreterAhoi::buildSend ( ahoi::packet_t  pck)

Method that builds the command to send a given message

Parameters
msgstring message to be sent through the modem
Returns
formatted string for sending msg

References serializePacket().

Here is the call graph for this function:

◆ buildSfdStat()

std::string UwInterpreterAhoi::buildSfdStat ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, serializePacket(), ahoi::sfdstat, and sn.

Here is the call graph for this function:

◆ buildSfdStatReset()

std::string UwInterpreterAhoi::buildSfdStatReset ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, serializePacket(), ahoi::sfdstatreset, and sn.

Here is the call graph for this function:

◆ buildSyncStat()

std::string UwInterpreterAhoi::buildSyncStat ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, serializePacket(), sn, and ahoi::syncstat.

Here is the call graph for this function:

◆ buildSyncStatReset()

std::string UwInterpreterAhoi::buildSyncStatReset ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, serializePacket(), sn, and ahoi::syncstatreset.

Here is the call graph for this function:

◆ buildTxGain()

std::string UwInterpreterAhoi::buildTxGain ( )

Method that builds the command

Returns
string containing the symbols of the command

References ahoi::commands_id, id, serializePacket(), sn, and ahoi::txgain.

Here is the call graph for this function:

◆ findResponse()

std::string UwInterpreterAhoi::findResponse ( std::vector< char >::iterator  beg,
std::vector< char >::iterator  end,
std::vector< char >::iterator &  rsp_beg,
std::vector< char >::iterator &  rsp_end 
)

Method that looks for ahoi! modem responses

Parameters
begbeginning of the region to search
endend of the region to search
rspbeginning of the modem response found by the method
Returns
boolean true if the method found a command

References dle, end_del, etx, ahoi::HEADER_LEN, and stx.

◆ fixEscapes()

void UwInterpreterAhoi::fixEscapes ( std::vector< char > &  buffer,
std::vector< char >::iterator &  c_beg,
std::vector< char >::iterator &  c_end 
)

Method that erases an escape (DLE) char if part of 2-cahrs escape sequence.

Parameters
iteratorpointing to the beginning of the response region
iteratorpointing to the end of the response region

References dle.

◆ parseResponse()

std::shared_ptr< ahoi::packet_t > UwInterpreterAhoi::parseResponse ( std::vector< char >::iterator  c_beg,
std::vector< char >::iterator  c_end 
)

Method that parses a region of memory where a response was previously found. This methods extracts the fields of the found response.

Parameters
iteratorpointing to the beginning of the response region
iteratorpointing to the end of the response region
Returns
packet filled with the correct fields

References beg_del, and end_del.

◆ serializePacket()

std::string UwInterpreterAhoi::serializePacket ( ahoi::packet_t *  packet)

Serialize the provided packet.

Parameters
packetthe ahoi::packet_t pck to be serialized
Returns
a vector of uint8_t of serialized data

References dle, etx, header_size, and stx.

Referenced by buildAgc(), buildAllStat(), buildAllStatReset(), buildBatVol(), buildDistance(), buildID(), buildPacketStat(), buildPacketStatReset(), buildRangeDelay(), buildReset(), buildRxGain(), buildSend(), buildSfdStat(), buildSfdStatReset(), buildSyncStat(), buildSyncStatReset(), and buildTxGain().

Member Data Documentation

◆ beg_del

std::array<uint8_t, 2> UwInterpreterAhoi::beg_del
private

Beginning delimiter

Referenced by parseResponse(), and UwInterpreterAhoi().

◆ dle

const uint8_t UwInterpreterAhoi::dle = 0x10
staticprivate

◆ end_del

std::array<uint8_t, 2> UwInterpreterAhoi::end_del
private

Ending delimiter

Referenced by findResponse(), parseResponse(), and UwInterpreterAhoi().

◆ etx

const uint8_t UwInterpreterAhoi::etx = 0x03
staticprivate

Ending sequence

Referenced by findResponse(), serializePacket(), and UwInterpreterAhoi().

◆ footer_size

uint UwInterpreterAhoi::footer_size = 6
staticprivate

Standard ahoi! packet has 6 bytes of header

◆ header_size

uint UwInterpreterAhoi::header_size = 6
staticprivate

Standard ahoi! packet has 6 bytes of header

Referenced by serializePacket().

◆ id

◆ sn

◆ stx

const uint8_t UwInterpreterAhoi::stx = 0x02
staticprivate

Starting sequence

Referenced by findResponse(), serializePacket(), and UwInterpreterAhoi().


The documentation for this class was generated from the following files: