DESERT 3.5.1
Loading...
Searching...
No Matches
uwinterpreters2c.h
Go to the documentation of this file.
1//
2// Copyright (c) 2019 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
37#ifndef UWINTERPRETERS2C_H
38#define UWINTERPRETERS2C_H
39
40#include <cstdarg>
41#include <iterator>
42#include <memory>
43#include <string>
44#include <vector>
45
49struct USBLInfo {
50 double curr_time;
51 double meas_time;
53 double X;
54 double Y;
55 double Z;
56 double E;
57 double N;
58 double U;
59 double accuracy;
60};
61
63{
64
65public:
110
114 virtual ~UwInterpreterS2C();
115
124 std::string buildSend(std::string msg, int dest);
125
135 std::string buildSendIM(std::string msg, int dest, bool ack);
136
143 std::string buildATZ(int level);
144
149 std::string buildGetATL();
150
156 std::string buildSetATL(int level);
157
162 std::string buildGetATAL();
163
169 std::string buildSetATAL(int addr);
170
175 std::string buildATDI();
176
183 std::string buildATS();
184
191 std::string buildATV();
192
202 UwInterpreterS2C::Response findResponse(std::vector<char>::iterator beg,
203 std::vector<char>::iterator end, std::vector<char>::iterator &rsp);
204
220 std::vector<char>::iterator end,
221 std::vector<char>::iterator rsp_beg,
222 std::vector<char>::iterator &rsp_end, std::string &rx_payload);
223
228 void setExtProtoMode(bool enabled);
229
235 std::shared_ptr<USBLInfo> getUSBLInfo();
236
237private:
238 std::string sep;
239 std::string r_term;
240 std::string w_term;
244 std::shared_ptr<USBLInfo> usbl_info;
252 static std::vector<std::pair<std::string, UwInterpreterS2C::Response> >
254};
255
256#endif
virtual ~UwInterpreterS2C()
Class destructor.
static std::vector< std::pair< std::string, UwInterpreterS2C::Response > > syntax_pool
Vector holding all possible commands for the S2C syntax and corresponding identifying token.
std::string buildATDI()
Method that builds the command to check the IM delivery status.
bool ext_proto_mode
Flag telling if Extened Protol Mode is in use.
std::shared_ptr< USBLInfo > getUSBLInfo()
Method to retrieve the USBL information saved upon reception of a USBL message.
std::string buildATV()
Method that builds the command to ask for current settings: it enlists source level,...
UwInterpreterS2C()
Class constructor.
Response
Enum listing the types of commands that could be received or sent by a S2C device; See the EvoLogics ...
std::string buildSetATAL(int addr)
Method that builds the command to set the local address of the device.
std::string buildATZ(int level)
Method that builds a reboot sequence: depending on the provided index different levels of reset can b...
std::string buildGetATL()
Method that builds the command to get the source level of the device.
std::string w_term
Terminating sequence for commands wrtten to device.
UwInterpreterS2C::Response findResponse(std::vector< char >::iterator beg, std::vector< char >::iterator end, std::vector< char >::iterator &rsp)
Method to look for S2C response inside a provided chunk of unparsed data This method only finds the b...
bool parseResponse(UwInterpreterS2C::Response rsp, std::vector< char >::iterator end, std::vector< char >::iterator rsp_beg, std::vector< char >::iterator &rsp_end, std::string &rx_payload)
Method that tries to parse a found response: if the response section of the buffer,...
std::string sep
Separator for paramters fo the commands: a comma.
void setExtProtoMode(bool enabled)
Method that sets whether Extended Protocol Mode is used or not.
std::string r_term
Terminating sequence for commands read from device.
std::string buildSendIM(std::string msg, int dest, bool ack)
Method that builds the command to send data through SENDIM command SENDIM is used to send Instant Mes...
std::shared_ptr< USBLInfo > usbl_info
Strucure holding info retrived via USBL message.
std::string buildATS()
Method that builds the command to ask for modem status: it enlists local address, acoustic link statu...
std::string buildSetATL(int level)
Method that builds the command to set the source level of the device.
std::string buildSend(std::string msg, int dest)
Method that builds the command to send data through SEND command SEND is used to send burst data: pay...
std::string buildGetATAL()
Method that builds the command to set the local address of the device.
Structure holding the info retreived via USBL message.
double accuracy
double meas_time
double curr_time