OpenDaVINCI  4.16.0
odcore::wrapper::SerialPort Class Reference

#include <SerialPort.h>

Inheritance diagram for odcore::wrapper::SerialPort:
Inheritance graph

Public Member Functions

 SerialPort (const string &port, const uint32_t &baudRate)
virtual ~SerialPort ()
void setConnectionListener (odcore::io::ConnectionListener *cl)
void setStringListener (odcore::io::StringListener *sl)
void start ()
void stop ()
void send (const string &data)

Protected Member Functions

virtual bool isRunning ()
virtual void run ()
void receivedString (const string &partialData)
void invokeConnectionListener ()

Detailed Description

This class provides a platform-independent serial port encapsulation.

Constructor & Destructor Documentation

odcore::wrapper::SerialPort::SerialPort ( const string &  port,
const uint32_t &  baudRate 

Constructor for enforcing subclasses for this class.

portSerial port.
baudRateBaud rate.

References odcore::wrapper::MutexFactory::createMutex(), and odcore::wrapper::ConcurrencyFactory::createThread().

odcore::wrapper::SerialPort::~SerialPort ( )

Member Function Documentation

void odcore::wrapper::SerialPort::invokeConnectionListener ( )

This method is called by subclasses to invoke the connection listener.

References odcore::io::ConnectionListener::handleConnectionError().

Referenced by run(), and send().

bool odcore::wrapper::SerialPort::isRunning ( )

This method returns true, iff this runnable is in its internal state for running.

true iff this runnable is in its internal state for running.

Implements odcore::wrapper::Runnable.

void odcore::wrapper::SerialPort::receivedString ( const string &  partialData)

This method has to be called by subclasses whenever new (partial) data was received. This method is responsible for gathering partial data and invoking the registered StringListener when a complete data packet was gathered.

partialDataPartially received data that will be gathered until the complete data can be passed to the registered StringListener.

References odcore::io::StringListener::nextString().

Referenced by run().

void odcore::wrapper::SerialPort::run ( )

This method implements the body of the function to be "threadified".

Implements odcore::wrapper::Runnable.

References invokeConnectionListener(), and receivedString().

void odcore::wrapper::SerialPort::send ( const string &  data)

This method sends data.

param data Data to be sent.

Implements odcore::io::StringSender.

References invokeConnectionListener().

void odcore::wrapper::SerialPort::setConnectionListener ( odcore::io::ConnectionListener cl)

This method registers a ConnectionListener that will be informed about connection errors.

clThe ConnectionListener

Implements odcore::io::ConnectionObserver.

Referenced by ~SerialPort().

void odcore::wrapper::SerialPort::setStringListener ( odcore::io::StringListener sl)

This method sets the StringListener that will realize the protocol.

slStringListener that will handle incoming data.

Referenced by ~SerialPort().

void odcore::wrapper::SerialPort::start ( )

This method must be called to start the connection.

void odcore::wrapper::SerialPort::stop ( )

This method closes a connection.