YARP
Yet Another Robot Platform
yarp::dev::ISerialDevice Class Referenceabstract

A generic interface to serial port devices. More...

#include <yarp/dev/ISerialDevice.h>

+ Inheritance diagram for yarp::dev::ISerialDevice:

Public Member Functions

virtual ~ISerialDevice ()
 
virtual bool send (const yarp::os::Bottle &msg)=0
 Sends a string of chars to the serial communications channel. More...
 
virtual bool send (char *msg, size_t size)=0
 
virtual bool receive (yarp::os::Bottle &msg)=0
 Gets the existing chars in the receive queue. More...
 
virtual int receiveChar (char &chr)=0
 Gets one single char from the receive queue. More...
 
virtual int receiveBytes (unsigned char *bytes, const int size)=0
 Gets an array of bytes (unsigned char) with size <= 'size' parameter. More...
 
virtual int receiveLine (char *line, const int MaxLineLength)=0
 Gets one line (a sequence of chars with a ending '\n' or '\r') from the receive queue. More...
 
virtual bool setDTR (bool enable)=0
 Enable/Disable DTR protocol. More...
 
virtual int flush ()=0
 Flushes the internal buffer. More...
 

Detailed Description

A generic interface to serial port devices.

Definition at line 27 of file ISerialDevice.h.

Constructor & Destructor Documentation

◆ ~ISerialDevice()

yarp::dev::ISerialDevice::~ISerialDevice ( )
virtualdefault

Member Function Documentation

◆ flush()

virtual int yarp::dev::ISerialDevice::flush ( )
pure virtual

Flushes the internal buffer.

Returns
the number of flushed characters.

Implemented in ServerSerial, and SerialDeviceDriver.

◆ receive()

virtual bool yarp::dev::ISerialDevice::receive ( yarp::os::Bottle msg)
pure virtual

Gets the existing chars in the receive queue.

Parameters
msgthe received string
Returns
true on success; false if no messages available

Implemented in ServerSerial, and SerialDeviceDriver.

◆ receiveBytes()

virtual int yarp::dev::ISerialDevice::receiveBytes ( unsigned char *  bytes,
const int  size 
)
pure virtual

Gets an array of bytes (unsigned char) with size <= 'size' parameter.

The array is NOT null terminated.

Parameters
bytesa previously allocated buffer where the received data is stored.
sizethe size of the 'bytes' parameter.
Returns
the number of received bytes. The function returns 0 if no bytes are received.

Implemented in ServerSerial, and SerialDeviceDriver.

◆ receiveChar()

virtual int yarp::dev::ISerialDevice::receiveChar ( char &  chr)
pure virtual

Gets one single char from the receive queue.

Parameters
chrthe received char.
Returns
0 if no chars are received; 1 if one char is received.

Implemented in SerialDeviceDriver, and ServerSerial.

◆ receiveLine()

virtual int yarp::dev::ISerialDevice::receiveLine ( char *  line,
const int  MaxLineLength 
)
pure virtual

Gets one line (a sequence of chars with a ending '\n' or '\r') from the receive queue.

The ending '\n''\r' chars are not removed in the returned line.

Parameters
linea previously allocated buffer where the received line is stored.
MaxLineLengththe size of the 'line' parameter.
Returns
the number of received characters (including the '
''\r' chars, plus the buffer terminator '\0'). The function returns 0 if no chars are received.

Implemented in ServerSerial, and SerialDeviceDriver.

◆ send() [1/2]

virtual bool yarp::dev::ISerialDevice::send ( char *  msg,
size_t  size 
)
pure virtual

Implemented in ServerSerial, and SerialDeviceDriver.

◆ send() [2/2]

virtual bool yarp::dev::ISerialDevice::send ( const yarp::os::Bottle msg)
pure virtual

Sends a string of chars to the serial communications channel.

Parameters
msgthe string to send
Returns
true on success

Implemented in ServerSerial, and SerialDeviceDriver.

◆ setDTR()

virtual bool yarp::dev::ISerialDevice::setDTR ( bool  enable)
pure virtual

Enable/Disable DTR protocol.

Parameters
enableEnable/Disable DTR protocol
Returns
true on success

Implemented in SerialDeviceDriver, and ServerSerial.


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