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

#include <uwserial.h>

Inheritance diagram for UwSerial:
Collaboration diagram for UwSerial:

Public Member Functions

 UwSerial ()
 
virtual ~UwSerial ()
 
virtual bool openConnection (const std::string &path)
 
virtual bool closeConnection ()
 
virtual const bool isConnected ()
 
virtual int writeToDevice (const std::string &msg)
 
virtual int readFromDevice (void *wpos, int maxlen)
 
virtual int configurePort (const std::string &path)
 
virtual bool refreshConnection (const std::string &path)
 
- Public Member Functions inherited from UwConnector
 UwConnector ()
 
virtual ~UwConnector ()
 
virtual void setServer ()
 
virtual void setTCP ()
 
virtual void setUDP ()
 
virtual const int getErrno ()
 

Private Attributes

int serialfd
 
struct termios tty
 

Additional Inherited Members

- Protected Attributes inherited from UwConnector
int local_errno
 

Detailed Description

Class that implements serial port connection.

Definition at line 52 of file uwserial.h.

Constructor & Destructor Documentation

◆ UwSerial()

UwSerial::UwSerial ( )

Constructor of the UwSerial class.

Definition at line 35 of file uwserial.cpp.

◆ ~UwSerial()

UwSerial::~UwSerial ( )
virtual

Destructor of the UwSerial class.

Definition at line 42 of file uwserial.cpp.

Member Function Documentation

◆ closeConnection()

bool UwSerial::closeConnection ( )
virtual

Method that closes an active connection to a device.

Returns
boolean true if connection is correctly closed, false otherwise

Implements UwConnector.

Definition at line 86 of file uwserial.cpp.

◆ configurePort()

int UwSerial::configurePort ( const std::string &  path)
virtual

Method that loads the termios struct with the serial port parameters.

Parameters
pathconst std::string with address and flag

Definition at line 123 of file uwserial.cpp.

◆ isConnected()

const bool UwSerial::isConnected ( )
virtual

Returns true if serial port fd differs from -1, that means the connection is up.

Returns
if serial port file descriptor is valid

Implements UwConnector.

Definition at line 47 of file uwserial.cpp.

◆ openConnection()

bool UwSerial::openConnection ( const std::string &  path)
virtual

Method that opens a serial connection, the input string has to be with a format like <port_name>:parity:stop:flow:baud, e.g.

tty0:p=0:s=1:f=0:b=123456

Returns
boolean true if connection is correctly opened, false otherwise

Implements UwConnector.

Definition at line 53 of file uwserial.cpp.

◆ readFromDevice()

int UwSerial::readFromDevice ( void *  wpos,
int  maxlen 
)
virtual

Function that receives data from the device's port to a backup buffer.

The unloaded data is saved to a temporary buffer, to be parsed later.

Parameters
posposition to start writing data to: a pointer to some buffer
Returns
integer number of read bytes

Implements UwConnector.

Definition at line 109 of file uwserial.cpp.

◆ refreshConnection()

bool UwSerial::refreshConnection ( const std::string &  path)
virtual

Method that refreshes an existing connection creating a new file descriptor.

Parameters
pathconst std::string with address and flag

Definition at line 261 of file uwserial.cpp.

◆ writeToDevice()

int UwSerial::writeToDevice ( const std::string &  msg)
virtual

Method that writes a command to the port interface.

Parameters
msgstd::string command to be sent through the port

Implements UwConnector.

Definition at line 97 of file uwserial.cpp.

Member Data Documentation

◆ serialfd

int UwSerial::serialfd
private

Integer value that stores the serial port descriptor as generated by the function UwSerial:openConnection().

Definition at line 119 of file uwserial.h.

◆ tty

struct termios UwSerial::tty
private

Definition at line 121 of file uwserial.h.


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