DESERT 3.5.1
Loading...
Searching...
No Matches
UwEvoLogicsS2CModem Class Reference

#include <uwevologicss2cmodem.h>

Inheritance diagram for UwEvoLogicsS2CModem:
Collaboration diagram for UwEvoLogicsS2CModem:

Public Types

enum class  TransmissionMode { BURST = 0 , IM = 1 }
 
enum class  TransmissionState { TX_IDLE = 0 , TX_PENDING }
 
- Public Types inherited from UwModem
enum class  LogLevel { ERROR = 0 , INFO = 1 , DEBUG = 2 }
 

Public Member Functions

 UwEvoLogicsS2CModem ()
 
virtual ~UwEvoLogicsS2CModem ()
 
virtual void recv (Packet *p)
 
virtual int command (int argc, const char *const *argv)
 
virtual int recvSyncClMsg (ClMessage *m)
 
virtual double getTxDuration (Packet *p)
 
virtual bool configure (Config cmd)
 
virtual void initializeLUT ()
 
- Public Member Functions inherited from UwModem
 UwModem ()
 
virtual ~UwModem ()
 
virtual int getModulationType (Packet *P)
 
void setModemID (int ID)
 
int getModemID ()
 
void printOnLog (LogLevel log_level, string module, string message)
 
LogLevel getLogLevel ()
 
int getDebug ()
 
std::string getLogFile ()
 
void realTxEnded (Packet *p)
 

Private Types

enum class  Config {
  ATL_GET , ATL_SET , ATAL_GET , ATAL_SET ,
  MODEM_STATUS , CURR_SETTINGS , UNKNOWN
}
 

Private Member Functions

virtual void startTx (Packet *p)
 
virtual void startRx (Packet *p)
 
virtual void endRx (Packet *p)
 
virtual void start ()
 
virtual void stop ()
 
virtual void transmittingData ()
 
virtual void receivingData ()
 
void updateStatus (UwInterpreterS2C::Response cmd)
 
void setFailedTx (Packet *p)
 
void createRxPacket (Packet *p)
 

Private Attributes

std::unique_ptr< UwConnectorp_connector
 
std::unique_ptr< UwInterpreterS2Cp_interpreter
 
ModemState status
 
TransmissionState tx_status
 
std::mutex status_m
 
std::mutex tx_status_m
 
std::mutex tx_queue_m
 
std::condition_variable status_cv
 
std::condition_variable tx_status_cv
 
std::condition_variable tx_queue_cv
 
std::atomic< bool > receiving
 
std::atomic< bool > transmitting
 
std::atomic< bool > im_status_updated
 
std::thread rx_thread
 
std::thread tx_thread
 
std::string rx_payload
 
TransmissionMode tx_mode
 
bool ack_mode
 
double virtual_time_ref
 
int curr_source_level
 
int n_rx_failed
 
int pend_source_level
 
bool source_level_change
 
TransmissionDurationLUT size2dur_
 
std::string txdur_file_name_
 
char txdur_token_separator_
 
bool initLUT_
 

Static Private Attributes

static const std::chrono::milliseconds MODEM_TIMEOUT
 
static const std::chrono::milliseconds WAIT_DELIVERY_IM
 
static const std::chrono::seconds WAIT_DELIVERY_BURST
 
static const double EPSILON_S
 
static uint MAX_N_STATUS_QUERIES = 10
 

Additional Inherited Members

- Static Public Member Functions inherited from UwModem
static bool string2log (const std::string &ll_string, LogLevel &ll)
 
static bool log2string (LogLevel ll, std::string &ll_string)
 
- Protected Member Functions inherited from UwModem
virtual void endTx (Packet *p)
 
void checkEvent ()
 
- Protected Attributes inherited from UwModem
int modemID
 
std::vector< char > data_buffer
 
std::queue< Packet * > tx_queue
 
std::queue< Packet * > rx_queue
 
unsigned int DATA_BUFFER_LEN
 
int MAX_READ_BYTES
 
std::string modem_address
 
int debug_
 
std::ofstream outLog
 
std::string logFile
 
std::string log_suffix
 
LogLevel loglevel_
 
bool log_is_open
 
CheckTimercheckTimer
 
double period
 
std::queue< ModemEventevent_q
 

Detailed Description

Definition at line 65 of file uwevologicss2cmodem.h.

Member Enumeration Documentation

◆ Config

enum class UwEvoLogicsS2CModem::Config
strongprivate

Enum listing the availbale configuration settings.

See the EvoLogics S2C manuals or reach for www.evologics.de

Enumerator
ATL_GET 
ATL_SET 
ATAL_GET 
ATAL_SET 
MODEM_STATUS 
CURR_SETTINGS 
UNKNOWN 

Definition at line 71 of file uwevologicss2cmodem.h.

◆ TransmissionMode

Transmission mode: either IM or BURST See the EvoLogics S2C manuals or reach for www.evologics.de.

Enumerator
BURST 
IM 

Definition at line 85 of file uwevologicss2cmodem.h.

◆ TransmissionState

Transmission state: controls the flow of execution for sending commands to the S2C device.

Enumerator
TX_IDLE 
TX_PENDING 

Definition at line 91 of file uwevologicss2cmodem.h.

Constructor & Destructor Documentation

◆ UwEvoLogicsS2CModem()

UwEvoLogicsS2CModem::UwEvoLogicsS2CModem ( )

Constructor of the UwEvoLogicsS2CModem class.

Parameters
addressstring containing the address to connect to
buflenlenght in char of the data buffer
readlen length in char of a signle read from the connector

Definition at line 76 of file uwevologicss2cmodem.cpp.

◆ ~UwEvoLogicsS2CModem()

UwEvoLogicsS2CModem::~UwEvoLogicsS2CModem ( )
virtual

Destructor of the UwEvoLogicsS2CModem class.

Definition at line 111 of file uwevologicss2cmodem.cpp.

Member Function Documentation

◆ command()

int UwEvoLogicsS2CModem::command ( int  argc,
const char *const *  argv 
)
virtual

Tcl command interpreter: Method that maps Tcl commands into C++ methods.

Parameters
argcnumber of arguments in argv
argvarray of strings which are the command parameters (Note that argv[0] is the name of the object).
Returns
TCL_OK or TCL_ERROR whether the command has been dispatched successfully or not

Reimplemented from UwModem.

Definition at line 161 of file uwevologicss2cmodem.cpp.

◆ configure()

bool UwEvoLogicsS2CModem::configure ( Config  cmd)
virtual

Method that sends a written configuration the the EvoLgoics modem.

The configuration string could be a request of configurations (the AT commands conaining '?') or a setting command (the AT commands containing '!').

Parameters
commandthe command string complying with the device format requirements.
Returns
boolean true if the command was correctly sent to the device

Definition at line 386 of file uwevologicss2cmodem.cpp.

◆ createRxPacket()

void UwEvoLogicsS2CModem::createRxPacket ( Packet *  p)
private

Method that fills up a packet with the needed header and payload and makes it ready to be sent to the layer above.

Parameters
pinstance of an empty packet to be filled

Definition at line 961 of file uwevologicss2cmodem.cpp.

◆ endRx()

void UwEvoLogicsS2CModem::endRx ( Packet *  p)
privatevirtual

Method that ends a packet reception.

This method is also in charge of sending the received NS-MIRACLE packet to the upper layers

Parameters
pPacket pointer to the packet being sent

Implements UwModem.

Definition at line 569 of file uwevologicss2cmodem.cpp.

◆ getTxDuration()

double UwEvoLogicsS2CModem::getTxDuration ( Packet *  p)
virtual

Method that return the duration of a given transmitted packet.

Inherited from MPhy, in NS-MIRACLE, could be empty if there is no way to retrieve this information.

Parameters
pPacket pointer to the given packet being transmitted
Returns
duration in seconds

Reimplemented from UwModem.

Definition at line 370 of file uwevologicss2cmodem.cpp.

◆ initializeLUT()

void UwEvoLogicsS2CModem::initializeLUT ( )
virtual

Method that loads the TX LUT into a map.

Also adds the processing delay if any.

Definition at line 235 of file uwevologicss2cmodem.cpp.

◆ receivingData()

void UwEvoLogicsS2CModem::receivingData ( )
privatevirtual

Mehod that detach a thread devoted to receiving data from the connector.

Definition at line 657 of file uwevologicss2cmodem.cpp.

◆ recv()

void UwEvoLogicsS2CModem::recv ( Packet *  p)
virtual

Method that handles the reception of packets arriving from upper layers of the network simulator.

Parameters
ppointer to the packet that has been received from the simulator upper layers

Implements UwModem.

Definition at line 117 of file uwevologicss2cmodem.cpp.

◆ recvSyncClMsg()

int UwEvoLogicsS2CModem::recvSyncClMsg ( ClMessage *  m)
virtual

Cross-Layer messages synchronous interpreter.

Parameters
ClMessage*an instance of ClMessage that represent the message received
Returns
0 if successful.

Implements UwModem.

Definition at line 297 of file uwevologicss2cmodem.cpp.

◆ setFailedTx()

void UwEvoLogicsS2CModem::setFailedTx ( Packet *  p)
private

Method that allows to set the error flag on the packet to notify upper layers about un-tranmsitted packets due to, e.g., modem unavailability.

Parameters
pPacket pointer ot the packet being transmitted

Definition at line 954 of file uwevologicss2cmodem.cpp.

◆ start()

void UwEvoLogicsS2CModem::start ( )
privatevirtual

Method that starts the driver operations.

It performs all the needed operations to correctly fire up the device's driver.

Implements UwModem.

Definition at line 576 of file uwevologicss2cmodem.cpp.

◆ startRx()

void UwEvoLogicsS2CModem::startRx ( Packet *  p)
privatevirtual

Method that starts a packet reception.

This method is also in charge of sending a ClMsg, Phy2MacStartRx(p), to notify the upper layers of the simulator about the start of the reception

Parameters
pPacket pointer to the packet to be received

Implements UwModem.

Definition at line 560 of file uwevologicss2cmodem.cpp.

◆ startTx()

void UwEvoLogicsS2CModem::startTx ( Packet *  p)
privatevirtual

Method that triggers the transmission of a packet through a specified modem.

Parameters
pPacket pointer to the packet to be sent

Implements UwModem.

Definition at line 448 of file uwevologicss2cmodem.cpp.

◆ stop()

void UwEvoLogicsS2CModem::stop ( )
privatevirtual

Method that stops the driver operations.

It performs all the needed operations to correctly stop the device's driver before closing the simulation.

Implements UwModem.

Definition at line 608 of file uwevologicss2cmodem.cpp.

◆ transmittingData()

void UwEvoLogicsS2CModem::transmittingData ( )
privatevirtual

Method that detach a thread devoted to sending packets found in tx_queue.

Definition at line 632 of file uwevologicss2cmodem.cpp.

◆ updateStatus()

void UwEvoLogicsS2CModem::updateStatus ( UwInterpreterS2C::Response  cmd)
private

Method that updates the status of the modem State Machine: state change is triggered by reception of commands on the connector interface, or by commands to be sent to the device, e.g., SEND or SENDIM.

Parameters
cmdcommand received on the connector interface

Definition at line 713 of file uwevologicss2cmodem.cpp.

Member Data Documentation

◆ ack_mode

bool UwEvoLogicsS2CModem::ack_mode
private

Set to true to enable IM ack.

Definition at line 272 of file uwevologicss2cmodem.h.

◆ curr_source_level

int UwEvoLogicsS2CModem::curr_source_level
private

Current source level already set in device.

Definition at line 274 of file uwevologicss2cmodem.h.

◆ EPSILON_S

const double UwEvoLogicsS2CModem::EPSILON_S
staticprivate

Minimum time to wait before to schedule a new event in seconds.

Definition at line 286 of file uwevologicss2cmodem.h.

◆ im_status_updated

std::atomic<bool> UwEvoLogicsS2CModem::im_status_updated
private

Atomic boolean variable controlling if the modem had responded to ATDI.

Definition at line 255 of file uwevologicss2cmodem.h.

◆ initLUT_

bool UwEvoLogicsS2CModem::initLUT_
private

Flag that tells whether the TX duration LUT is loaded or not.

Definition at line 283 of file uwevologicss2cmodem.h.

◆ MAX_N_STATUS_QUERIES

uint UwEvoLogicsS2CModem::MAX_N_STATUS_QUERIES = 10
staticprivate

Maximum number of time to query the modem transmission status before to discard the transmitted packet.

Definition at line 289 of file uwevologicss2cmodem.h.

◆ MODEM_TIMEOUT

const std::chrono::milliseconds UwEvoLogicsS2CModem::MODEM_TIMEOUT
staticprivate
Initial value:
=
std::chrono::milliseconds(210)

Maximum time to wait for modem to become ModemState::AVAILABLE.

Definition at line 263 of file uwevologicss2cmodem.h.

◆ n_rx_failed

int UwEvoLogicsS2CModem::n_rx_failed
private

Number of failed receptions up to now.

Definition at line 275 of file uwevologicss2cmodem.h.

◆ p_connector

std::unique_ptr<UwConnector> UwEvoLogicsS2CModem::p_connector
private

Pointer to Connector object that interfaces with the device.

Definition at line 229 of file uwevologicss2cmodem.h.

◆ p_interpreter

std::unique_ptr<UwInterpreterS2C> UwEvoLogicsS2CModem::p_interpreter
private

Pointer to Interpreter object to parse device syntax.

Definition at line 231 of file uwevologicss2cmodem.h.

◆ pend_source_level

int UwEvoLogicsS2CModem::pend_source_level
private

Pending source level, requested but not set.

Definition at line 276 of file uwevologicss2cmodem.h.

◆ receiving

std::atomic<bool> UwEvoLogicsS2CModem::receiving
private

Atomic boolean variable that controls the receiving looping thread.

Definition at line 251 of file uwevologicss2cmodem.h.

◆ rx_payload

std::string UwEvoLogicsS2CModem::rx_payload
private

String that is updated witn each new received messsage.

Definition at line 261 of file uwevologicss2cmodem.h.

◆ rx_thread

std::thread UwEvoLogicsS2CModem::rx_thread
private

Object with the rx thread.

Definition at line 257 of file uwevologicss2cmodem.h.

◆ size2dur_

TransmissionDurationLUT UwEvoLogicsS2CModem::size2dur_
private

Map from size [byte] to TX duration [s].


Definition at line 280 of file uwevologicss2cmodem.h.

◆ source_level_change

bool UwEvoLogicsS2CModem::source_level_change
private

Flag that tells a new SL value to be applied.

Definition at line 277 of file uwevologicss2cmodem.h.

◆ status

ModemState UwEvoLogicsS2CModem::status
private

Variable holding the current status of the modem.

Definition at line 233 of file uwevologicss2cmodem.h.

◆ status_cv

std::condition_variable UwEvoLogicsS2CModem::status_cv
private

Condition variable to wait for ModemState::AVAILABLE.

Definition at line 245 of file uwevologicss2cmodem.h.

◆ status_m

std::mutex UwEvoLogicsS2CModem::status_m
private

Mutex associated with the state machine of the modem.

Definition at line 239 of file uwevologicss2cmodem.h.

◆ transmitting

std::atomic<bool> UwEvoLogicsS2CModem::transmitting
private

Atomic boolean variable that controls the transmitting looping thread.

Definition at line 253 of file uwevologicss2cmodem.h.

◆ tx_mode

TransmissionMode UwEvoLogicsS2CModem::tx_mode
private

Either burst or im.

Definition at line 271 of file uwevologicss2cmodem.h.

◆ tx_queue_cv

std::condition_variable UwEvoLogicsS2CModem::tx_queue_cv
private

Condition variable that is linked with the transmitting queue.

Definition at line 249 of file uwevologicss2cmodem.h.

◆ tx_queue_m

std::mutex UwEvoLogicsS2CModem::tx_queue_m
private

Mutex associated with the transmission queue.

Definition at line 243 of file uwevologicss2cmodem.h.

◆ tx_status

TransmissionState UwEvoLogicsS2CModem::tx_status
private

Variable holding the current transmission status of the modem.

Definition at line 235 of file uwevologicss2cmodem.h.

◆ tx_status_cv

std::condition_variable UwEvoLogicsS2CModem::tx_status_cv
private

Condition variable to wait for TransmissionState::TX_IDLE.

Definition at line 247 of file uwevologicss2cmodem.h.

◆ tx_status_m

std::mutex UwEvoLogicsS2CModem::tx_status_m
private

Mutex associated with the transmission state machine of the modem.

Definition at line 241 of file uwevologicss2cmodem.h.

◆ tx_thread

std::thread UwEvoLogicsS2CModem::tx_thread
private

Object with the tx thread.

Definition at line 259 of file uwevologicss2cmodem.h.

◆ txdur_file_name_

std::string UwEvoLogicsS2CModem::txdur_file_name_
private

TX duration LUT file name.

Definition at line 281 of file uwevologicss2cmodem.h.

◆ txdur_token_separator_

char UwEvoLogicsS2CModem::txdur_token_separator_
private

TX duration LUT separator.

Definition at line 282 of file uwevologicss2cmodem.h.

◆ virtual_time_ref

double UwEvoLogicsS2CModem::virtual_time_ref
private

virtual time reference

Definition at line 273 of file uwevologicss2cmodem.h.

◆ WAIT_DELIVERY_BURST

const std::chrono::seconds UwEvoLogicsS2CModem::WAIT_DELIVERY_BURST
staticprivate
Initial value:
=
std::chrono::seconds(5)

Time interval tu wait for a burst message tobe confirmed through a DELIVERED response.

Given in SECONDS

Definition at line 269 of file uwevologicss2cmodem.h.

◆ WAIT_DELIVERY_IM

const std::chrono::milliseconds UwEvoLogicsS2CModem::WAIT_DELIVERY_IM
staticprivate
Initial value:
=
std::chrono::milliseconds(200)

Time interval to wait for the modem notifying that there no more IM in its queue and a new IM can be sent.

Definition at line 266 of file uwevologicss2cmodem.h.


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