37#include <uwmphy_modem.h>
44 const char *data = str.c_str();
46 std::cout << name <<
"[" << len <<
"]: " << std::hex;
47 for (
int i = 0; i < len; i++) {
50 std::cout << std::right << (
unsigned int) (
unsigned char) data[i];
52 if (std::isalnum(data[i]) || std::ispunct(data[i]))
53 std::cout <<
"(" << data[i] <<
")";
58 std::cout << std::dec << std::endl;
65 const char *data = str.c_str();
66 std::string str_out =
"";
68 for (
int i = 0; i < len; i++) {
69 if (std::isalnum(data[i]) || std::ispunct(data[i]))
73 std::stringstream sstr(
"");
74 sstr <<
"[" << std::hex << (
unsigned int) (
unsigned char) data[i]
87 const char *data = str.c_str();
89 std::string str_out =
"";
91 for (
int i = 0; i < len; i++) {
92 if (std::isalnum(data[i]) || std::ispunct(data[i]))
96 std::stringstream sstr(
"");
97 sstr << std::hex << (
unsigned int) (
unsigned char) data[i];
109 , mConnector(this, pmModem_->getPathToDevice())
138 while (q_msg !=
"") {
174 std::stringstream sstr(
"");
193 std::string parser(
"\n");
195 size_t p_parser = rx_msg.find(parser);
199 while (!rx_msg.empty() && p_parser == std::string::npos) {
202 p_parser = rx_msg.find(parser);
205 while (p_parser != std::string::npos) {
206 pr_msg = rx_msg.substr(
207 p_offset, p_parser + parser.size() - p_offset);
208 if (pr_msg.find(
"TELEGRAM_ACCEPTED") != string::npos) {
211 if (pr_msg.find(
"TELEGRAM_SENT") != string::npos ||
212 pr_msg.find(
"GPIO") != string::npos ||
213 pr_msg.find(
"DSP_READY_TO_START") != string::npos ||
214 pr_msg.find(
"LISTENING_EXPIRED") != string::npos ||
215 pr_msg.find(
"CONFIG_DONE") != string::npos ||
216 pr_msg.find(
"BITRATE") != string::npos) {
219 p_offset += pr_msg.size();
220 p_parser = rx_msg.find(parser, p_offset + 1);
239 if (rx_msg.find(
"TELEGRAM_SENT") != std::string::npos)
240 if (rx_msg.find(
"4114") != std::string::npos) {
241 std::stringstream sstr(
"");
243 sstr <<
"UPDATE_STATUS::PROCESSING_ERROR::" <<
status
244 <<
"_M_STATUS_TX_" <<
m_state_tx <<
"_M_STATUS_RX_"
253 std::stringstream sstr(
"");
255 sstr <<
"UPDATE_STATUS::PROCESSING_OK::" <<
status
256 <<
"_M_STATUS_TX_" <<
m_state_tx <<
"_M_STATUS_RX_"
265 else if (rx_msg.find(
"DSP_READY_TO_START") != string::npos) {
266 std::stringstream sstr(
"");
268 sstr <<
"UPDATE_STATUS::POWERING_ON_OK::" <<
status
269 <<
"_M_STATUS_TX_" <<
m_state_tx <<
"_M_STATUS_RX_"
277 }
else if (rx_msg.find(
"BITRATE") != string::npos) {
278 std::stringstream sstr(
"");
280 sstr <<
"UPDATE_STATUS::SETTING_BITRATE_OK::" <<
status
281 <<
"_M_STATUS_TX_" <<
m_state_tx <<
"_M_STATUS_RX_"
288 }
else if (rx_msg.find(
"LISTENING_EXPIRED") != string::npos) {
292 }
else if (rx_msg.find(
"CONFIG_DONE") != string::npos) {
293 std::stringstream sstr(
"");
295 sstr <<
"UPDATE_STATUS::CONFIGURING_DSP_OK::" <<
status
296 <<
"_M_STATUS_TX_" <<
m_state_tx <<
"_M_STATUS_RX_"
304 }
else if (rx_msg.find(
"tx_on") != string::npos) {
305 std::stringstream sstr(
"");
307 sstr <<
"UPDATE_STATUS::TX_PIN_CLEARED::" <<
m_state_tx
313 }
else if (rx_msg.find(
"ERROR") != string::npos) {
314 std::stringstream sstr(
"");
316 sstr <<
"UPDATE_STATUS::ERROR::" <<
m_state_tx <<
"_"
323 std::stringstream sstr(
"");
325 sstr <<
"UPDATE_STATUS::OK_WRONG_STATUS_" << rx_msg
335 std::stringstream sstr(
"");
337 sstr <<
"UPDATE_STATUS::END_RX::" <<
status <<
"_M_STATUS_TX_"
345 std::stringstream sstr(
"");
347 sstr <<
"UPDATE_STATUS::GOING_TO_LISTENING::" <<
status
362 if (rx_msg.find(
"TELEGRAM_ACCEPTED") != string::npos) {
363 std::stringstream sstr(
"");
366 sstr <<
"UPDATE_STATUS::DETECTED_DATA::" <<
payload_rx
374 }
else if (rx_msg.find(
"CONFIG_DONE") != string::npos) {
375 std::stringstream sstr(
"");
377 sstr <<
"UPDATE_STATUS::CONFIGURING_DSP_OK::" <<
status
378 <<
"_M_STATUS_TX_" <<
m_state_tx <<
"_M_STATUS_RX_"
399 std::stringstream sstr(
"");
416 sstr <<
"MODEM_TX_MANAGER::MODEM_START_DSP";
428 sstr <<
"MODEM_TX_MANAGER::MODEM_STOP_DSP";
434 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_RECV::" << tx_msg;
441 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_DATA::MSG::" << tx_msg;
448 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_CTRL::" << tx_msg;
455 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_DSP_CFG::" << tx_msg;
461 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_BITRATE_CFG::" << tx_msg;
467 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_ASK_BUSY::" << tx_msg;
473 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_STOP_LISTEN::" << tx_msg;
480 sstr <<
"MODEM_TX_MANAGER::TELEGRAM_CLEAR_TX::" << tx_msg;
enum MODEM_STATES modem_state_t
int _SL
Variable holding the Source Level of the low level driver.
void modemTx()
Method that notifies the driver that there is a packet to be sent via the modem.
ll_tx_state_t m_state_tx
TX state to manage transmission methods.
double _delay
Variable that holds the delay required for doing some operations, e.g., sending a message,...
int _chipset
Variable holding the chipset that will be used by the low level firmware.
void start()
Method to let the driver start operations and initialize configurations.
void stop()
Method to stop the driver operations.
int _delay_flag
Variable that holds that flag that triggers the waiting time for some operations e....
Msocket mConnector
Object that handles the physical host to modem communications via TCP/IP sockets.
std::queue< std::string > queue_tx
Queue used to buffer incoming strings for tx messages.
std::queue< std::string > queue_rx
Queue used to buffer incoming strings for rx messages.
ll_rx_state_t m_state_rx
RX state to manage reception methods.
void setBitrate(int index)
Method to set the bitrate that will be sent to the modem config.
void setPktBitLen(int bitlen)
Method to set the msg bitlength that will be received by rx.
MdriverS2C_Evo_lowlev(UWMPhy_modem *)
Class constructor.
int _gain
Variable holding the Gain level of the low level driver.
virtual modem_state_t updateStatus()
Method to update modem status.
int _th
Variable holding the threshold used by the low level firmware.
~MdriverS2C_Evo_lowlev()
Class destructor.
void setSourceLevel(int level)
Method to set the source level that will be sent to the modem config.
void updateTxState(ll_tx_state_t)
Method for updating the state after a significant change, namely: a configuration of the firmware par...
int _mps_th
Variable holding the MPS treshold used by the low level firmware.
virtual void modemSetID()
Method to set the ID of the modem.
int _msg_bitlen
Very very temporary parameter to let the receiver not screw up and read only the, known,...
void modemTxManager()
Method that manages the transmission of TELEGRAMS and configurations via GPIOs to the modem.
int _bitrate_i
Variable holding the bitrate index of the low level firmware.
MinterpreterTEL mInterpreter
Object that builds/parses TELEGRAMS and GPIO settings.
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.
std::string build_stop_listen()
Method which builds the TELEGRAM that makes the physical layer to exit the listen mode.
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.
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.
virtual int writeToModem(std::string)
Method for writing to the modem.
virtual int openConnection()
Method to open the connection with the modem.
virtual void closeConnection()
Method to close the connection with the modem.
The main class implementing the module used to implement the interface between ns2/NS-Miracle and rea...
std::string readFromModem()
Method to check the receiving modem buffer.
The class needed by UWMPhy_modem to handle the different transmissions cases and corresponding protoc...
std::string payload_tx
String where to save the payload of the next packet to send via modem.
void printOnLog(log_level_t log_level, std::string module, std::string message)
void setConnections(UWMinterpreter *, UWMconnector *)
Link connector.
modem_state_t status
Status of the driver's general state machine.
std::string payload_rx
String where to save the payload of the last packet received via modem.
static std::string hexdumplog(std::string str)
static void hexdump(std::string name, std::string str)
static std::string hexdumpdata(std::string str)
Class derived from UWMdriver to interface ns2/NS-Miracle with the S2C EvoLogics acoustic modems throu...
enum LL_STATE_TX ll_tx_state_t