47 const char *data = str.c_str();
49 std::cout << name <<
"[" << len <<
"]: " << std::hex;
50 for (
int i = 0; i < len; i++) {
53 std::cout << std::right << (int) data[i];
55 if (std::isalnum(data[i]) || std::ispunct(data[i]))
56 std::cout <<
"(" << data[i] <<
")";
61 std::cout << std::dec << std::endl;
68 const char *data = str.c_str();
70 std::string str_out =
"";
72 for (
int i = 0; i < len; i++) {
73 if (std::isalnum(data[i]) || std::ispunct(data[i]))
77 std::stringstream sstr(
"");
78 sstr <<
"[" << std::hex << (
unsigned int) (
unsigned char) data[i]
91 size_t len = str.size();
92 const char *data = str.c_str();
94 std::string str_out =
"";
96 for (
size_t i = 0; i < len; i++) {
97 std::stringstream sstr(
"");
100 sstr << std::hex << (
unsigned int) (
unsigned char) data[i] << std::dec;
101 str_out += sstr.str();
109 std::istringstream istr(str);
110 std::string str_out =
"";
111 std::string str_sym(
"");
113 while (std::getline(istr, str_sym,
' ')) {
116 std::stringstream sstr(
"");
117 sstr <<
"0x" << str_sym;
118 sstr >> std::hex >> symbol;
140 std::string turnon_string;
141 std::stringstream astr(
"");
144 astr <<
"gpio,clear,dsp_power";
147 astr <<
"gpio,set,ena_tx";
150 astr <<
"gpio,clear,fpga_reset";
153 astr <<
"gpio,clear,dsp_reset";
156 astr >> turnon_string;
157 return turnon_string;
163 std::string turnoff_string;
164 std::stringstream astr;
167 astr <<
"gpio,set,dsp_reset";
170 astr <<
"gpio,set,fpga_reset";
173 astr <<
"gpio,set,dsp_power";
176 astr >> turnoff_string;
177 return turnoff_string;
183 return "gpio,get,fpga_busy";
189 return "stop_listen";
194 int _gain,
int _chipset,
int _sl,
int _th,
int _mps_th)
196 std::string config_string;
197 std::stringstream astr(
"");
201 <<
"," << _gain <<
"," << _chipset <<
"," << _sl <<
"," << _th <<
","
204 astr >> config_string;
206 return config_string;
212 std::string recv_string;
213 std::stringstream astr;
214 if (msg_bytes != 0) {
215 astr <<
"rcv_sync_data"
216 <<
"," << msg_bytes <<
"," << _stop_f <<
"," << _delay;
218 astr <<
"rcv_sync_data"
221 <<
"," << _stop_f <<
"," << _delay;
230 std::string ctrl_telegram;
231 std::stringstream astr;
232 std::string hexdumped_ctrl;
238 int bitlen = _ctrl.size() * 8;
240 astr <<
"send_sync_ctrl"
241 <<
"," << bitlen <<
"," << _delay_f <<
"," << _delay <<
","
243 astr >> ctrl_telegram;
244 return ctrl_telegram;
250 std::string data_telegram;
251 std::stringstream astr;
252 std::string hexdumped_data;
258 int bitlen = hexdumped_data.size() * 4;
260 astr <<
"send_sync_data"
261 <<
"," << bitlen <<
"," << _delay_f <<
"," << _delay <<
","
263 astr >> data_telegram;
264 return data_telegram;
270 std::string bitrate_telegram;
271 std::stringstream astr;
272 if ((_bitrate < 0) || (_bitrate > 63)) {
273 std::cout <<
"ERROR: invalid bitrate code provided";
277 astr >> bitrate_telegram;
281 astr >> bitrate_telegram;
283 return bitrate_telegram;
289 std::string clear_command(
"gpio,clear,tx_on");
290 return clear_command;
298 std::string _len, _data, _bitlen, _data_flag, _integrity, _rms, _error_code;
299 std::string _rcv_time, _sync_detected_time, _nshift, _speed;
300 std::string _sync_delta_phase, _symbol_phase_std, _symbol_mean_phase, _mps;
302 std::istringstream iastr(telegram);
303 getline(iastr, _TEL,
',');
304 getline(iastr, _len,
',');
305 getline(iastr, _data,
',');
306 getline(iastr, _bitlen,
',');
307 getline(iastr, _data_flag,
',');
308 getline(iastr, _integrity,
',');
309 getline(iastr, _rms,
',');
310 getline(iastr, _error_code,
',');
312 getline(iastr, _rcv_time,
',');
313 getline(iastr, _sync_detected_time,
',');
314 getline(iastr, _nshift,
',');
315 getline(iastr, _speed,
',');
317 getline(iastr, _sync_delta_phase,
',');
318 getline(iastr, _symbol_phase_std,
',');
319 getline(iastr, _symbol_mean_phase,
',');
320 getline(iastr, _mps,
'\n');
325 std::string _data_p = _data.erase(0, 1);
326 _data_p = _data_p.erase(_data_p.size() - 1, 1);
std::string build_busy_FPGA()
Method which builds the string to ask the DSP if it is busy doing modulation/demodulation.
std::string build_send_data(std::string _data, int _delay_f, double _delay)
Method for building the TELEGRAM that will send DATA messages.
void parse_TELEGRAM(std::string telegram)
Method for parsing what is received upon receiving a TELEGRAM.
std::string build_poweron_DSP(int _step)
Method for building the string that allow turning on the DSP of the modem, which basically turns on t...
std::string build_clear_tx()
Method for building the COMMAND that will clear the tx_on pin.
std::string build_bitrate(int _bitrate)
Method for building the TELEGRAM that will set the bitrate used for transmission.
MinterpreterTEL(UWMdriver *)
Class constructor.
std::string build_stop_listen()
Method which builds the TELEGRAM that makes the physical layer to exit the listen mode.
~MinterpreterTEL()
Class destructor.
std::string build_send_ctrl(std::string _ctrl, int _delay_f, double _delay)
Method for building the TELEGRAM that will transmit CONTROL messages, which are short messanges of ma...
std::string build_recv_data(int msg_bytes, int _stop_f, double _delay)
Method for building the TELEGRAM that will allow receiving BITS, wheter CONTROL or DATA messages.
double rx_integrity
Integrity of the last received packet.
std::string build_poweroff_DSP(int _step)
Method for building the string for turning off the DSP of the modem which basically turns off the phy...
std::string build_config_DSP(int _gain, int _chipset, int _sl, int _th, int _mps_th)
Method for building the TELEGRAM that will allow configuring the DSP.
The class needed by UWMPhy_modem to handle the different transmissions cases and corresponding protoc...
void updateRx(int, int, std::string)
Method to write in UWMdriver::payload_rx, UWMdriver::src and UWMdriver::dstPktRx.
This class is in charge of building/parsing the necessary messages to make the UWMdriver able to comm...
UWMdriver * pmDriver
Link to the UWMdriver object which contains this UWMinterpreter object.
static std::string hexdumpdata(std::string str)
static std::string hexdumplog(std::string str)
static std::string dechexdumpdata(std::string str)
static void hexdump(std::string name, std::string str)
static std::string hexdumpdata(std::string str)
Class that is in charge of building and parsing the required messages to make the UWMdriver able to c...