DESERT 4.0.0
Msocket Class Reference

#include <msocket.h>

Inheritance diagram for Msocket:
Inheritance graph
Collaboration diagram for Msocket:
Collaboration graph

Public Member Functions

 Msocket (UWMdriver *, std::string)
 
 ~Msocket ()
 
virtual int openConnection ()
 
virtual void closeConnection ()
 
virtual int writeToModem (std::string)
 
int getSocket ()
 
 Msocket (UWMdriver *, std::string)
 
 ~Msocket ()
 
virtual int openConnection ()
 
virtual void closeConnection ()
 
virtual int writeToModem (std::string)
 
int getSocket ()
 
- Public Member Functions inherited from UWMconnector
 UWMconnector (UWMdriver *, std::string)
 
 ~UWMconnector ()
 
std::string readFromModem ()
 
void setDriverQueueLength (int length)
 
uint getDriverQueueLength ()
 
 UWMconnector (UWMdriver *, std::string)
 
 ~UWMconnector ()
 
std::string readFromModem ()
 
void setDriverQueueLength (int length)
 
uint getDriverQueueLength ()
 

Private Member Functions

void error (const char *)
 
void error (const char *)
 

Private Attributes

int sockfd
 
int portno
 
int rc
 
pthread_t thread_id
 
struct sockaddr_in serv_addr
 
std::string server_host
 
struct hostent * server
 
char msg_tx [_MAX_MSG_LENGTH]
 
int modem_queue_length
 

Additional Inherited Members

- Public Attributes inherited from UWMconnector
std::queue< msgModemqueueMsg
 
- Protected Attributes inherited from UWMconnector
UWMdriverpmDriver
 
std::string pathToDevice
 
uint driver_queue_length
 

Detailed Description

Class used to manage host/modem string exchange via TCP/IP connection (this class is a derived class of UWMconnector).

Constructor & Destructor Documentation

◆ Msocket() [1/2]

Msocket::Msocket ( UWMdriver pmDriver_,
std::string  portno_ 
)

Class constructor.

Parameters
pmDriver_pointer to the UWMdriver object to link with this UWMconnector object.
pathToDevice_the path to the device that must be connected with NS-Miracle (e.g., the port "9200" for a TCP/IP connection)

References UWMconnector::pathToDevice, portno, server_host, and sockfd.

◆ ~Msocket() [1/2]

Msocket::~Msocket ( )

Class destructor.

◆ Msocket() [2/2]

Msocket::Msocket ( UWMdriver ,
std::string   
)

Class constructor.

Parameters
pmDriver_pointer to the UWMdriver object to link with this UWMconnector object.
pathToDevice_the path to the device that must be connected with NS-Miracle (e.g., the port "9200" for a TCP/IP connection)

◆ ~Msocket() [2/2]

Msocket::~Msocket ( )

Class destructor.

Member Function Documentation

◆ closeConnection() [1/2]

virtual void Msocket::closeConnection ( )
virtual

Method to close the connection with the modem.

Reimplemented from UWMconnector.

◆ closeConnection() [2/2]

void Msocket::closeConnection ( )
virtual

Method to close the connection with the modem.

Reimplemented from UWMconnector.

References sockfd.

Referenced by MdriverS2C_Evo_lowlev::stop().

◆ error() [1/2]

void Msocket::error ( const char *  )
private

Method report errors.

Parameters
[in]msgpointer to an error message to report.

◆ error() [2/2]

void Msocket::error ( const char *  msg)
private

Method report errors.

Parameters
[in]msgpointer to an error message to report.

◆ getSocket() [1/2]

int Msocket::getSocket ( )
inline

Method to read the pointer to the socket where to write (it is needed by the reading function invoked by the parallel thread)

Returns
Msocket::sockfd

References sockfd.

◆ getSocket() [2/2]

int Msocket::getSocket ( )
inline

Method to read the pointer to the socket where to write (it is needed by the reading function invoked by the parallel thread)

Returns
Msocket::sockfd

References sockfd.

Referenced by read_process_msocket().

◆ openConnection() [1/2]

virtual int Msocket::openConnection ( )
virtual

Method to open the connection with the modem.

Returns
_MODEM_OK (see uwmconnector.h) if everything went fine, any other int value otherwise.

Implements UWMconnector.

◆ openConnection() [2/2]

int Msocket::openConnection ( )
virtual

Method to open the connection with the modem.

Returns
_MODEM_OK (see uwmconnector.h) if everything went fine, any other int value otherwise.

Implements UWMconnector.

References portno, rc, read_process_msocket(), serv_addr, server, server_host, sockfd, and thread_id.

Referenced by MdriverS2C_Evo_lowlev::start().

Here is the call graph for this function:

◆ writeToModem() [1/2]

virtual int Msocket::writeToModem ( std::string  )
virtual

Method for writing to the modem.

Parameters
[in]strthe string to pass to the modem
Returns
w_bytes, the number of transmitted bytes

Implements UWMconnector.

◆ writeToModem() [2/2]

int Msocket::writeToModem ( std::string  str)
virtual

Method for writing to the modem.

Parameters
[in]strthe string to pass to the modem
Returns
w_bytes, the number of transmitted bytes

Implements UWMconnector.

References msg_tx, and sockfd.

Referenced by MdriverS2C_Evo_lowlev::modemTxManager().

Member Data Documentation

◆ modem_queue_length

int Msocket::modem_queue_length
private

◆ msg_tx

char Msocket::msg_tx
private

Message to be transmitted host to modem.

Referenced by writeToModem().

◆ portno

int Msocket::portno
private

Port number.

Referenced by Msocket(), and openConnection().

◆ rc

int Msocket::rc
private

Indicator of the thread creation.

Referenced by openConnection().

◆ serv_addr

struct sockaddr_in Msocket::serv_addr
private

Structure to contain the Internet address to be used.

Referenced by openConnection().

◆ server

struct hostent * Msocket::server
private

Structure to define the server host.

Referenced by openConnection().

◆ server_host

std::string Msocket::server_host
private

Name of the server host on the Internet to which we want to be connected as client.

Referenced by Msocket(), and openConnection().

◆ sockfd

int Msocket::sockfd
private

Pointer to the socket.

Referenced by closeConnection(), getSocket(), Msocket(), openConnection(), and writeToModem().

◆ thread_id

pthread_t Msocket::thread_id
private

Id of a parallel thread.

Referenced by openConnection().


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