Serial-TCP/IPbridge  1.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SerialConnection Class Reference

Serial connection (via a serial port). More...

#include <serial_connection.h>

Inheritance diagram for SerialConnection:
Connection

Public Member Functions

 SerialConnection (const SerialConfig &config)
 Constructor. More...
 
virtual ~SerialConnection ()
 Destructor. More...
 
virtual void close ()
 Closes an established TCP connection. More...
 
- Public Member Functions inherited from Connection
 Connection (const Config &config, time_t timeout)
 Constructor. More...
 
virtual ~Connection ()
 Destructor. More...
 
std::string tryReceiveMessage ()
 Tries to receive a message from a client. More...
 
size_t trySendMessage (const std::string &message)
 Tries to send a message to the client. More...
 

Private Member Functions

virtual std::string doReceiveMessage (Config::LengthFieldMessageLength messageLength)
 Receives a message. More...
 
virtual size_t doSendMessage (const std::string &message)
 Sends the selected message. More...
 
 SerialConnection (const SerialConnection &)
 
SerialConnectionoperator= (const SerialConnection &)
 

Private Attributes

int _serialFd
 File descriptor to the serial port. More...
 

Detailed Description

Serial connection (via a serial port).

It provides reference semantics (objects copying and comparison is NOT allowed).

Constructor & Destructor Documentation

SerialConnection::SerialConnection ( const SerialConfig config)

Constructor.

Parameters
configConnection configuration.
virtual SerialConnection::~SerialConnection ( )
virtual

Destructor.

SerialConnection::SerialConnection ( const SerialConnection )
private

Member Function Documentation

virtual void SerialConnection::close ( )
virtual

Closes an established TCP connection.

If the connection is not established, nothing will happen.

Implements Connection.

virtual std::string SerialConnection::doReceiveMessage ( Config::LengthFieldMessageLength  messageLength)
privatevirtual

Receives a message.

Parameters
messageLengthLength of the message.
Returns
Received message.

This operation should be nonblocking.

If there is some error, ConnectionError will be thrown. If the connection is closed, ConnectionClosed will be thrown.

Implements Connection.

virtual size_t SerialConnection::doSendMessage ( const std::string &  message)
privatevirtual

Sends the selected message.

Parameters
messageMessage to be sent.
Returns
Number of sent bytes.

This operation should be nonblocking.

If there is some error, ConnectionError will be thrown. If the connection is closed, ConnectionClosed will be thrown.

Implements Connection.

SerialConnection& SerialConnection::operator= ( const SerialConnection )
private

Member Data Documentation

int SerialConnection::_serialFd
private

File descriptor to the serial port.


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