YARP
Yet Another Robot Platform

serialport: A basic Serial Communications Link (RS232, USB). More...

#include <serialport/SerialDeviceDriver.h>

+ Inheritance diagram for SerialDeviceDriver:

Public Member Functions

 SerialDeviceDriver ()
 
virtual ~SerialDeviceDriver ()
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver. More...
 
bool open (SerialDeviceDriverSettings &config)
 Configures the device. More...
 
bool close () override
 Close the DeviceDriver. More...
 
bool send (const Bottle &msg) override
 Sends a string of chars to the serial communications channel. More...
 
bool send (char *msg, size_t size) override
 
bool receive (Bottle &msg) override
 Gets the existing chars in the receive queue. More...
 
int receiveChar (char &chr) override
 Gets one single char from the receive queue. More...
 
int receiveBytes (unsigned char *bytes, const int size) override
 Gets an array of bytes (unsigned char) with size <= 'size' parameter. More...
 
int receiveLine (char *line, const int MaxLineLength) override
 Gets one line (a sequence of chars with a ending '\n' or '\r') from the receive queue. More...
 
bool setDTR (bool value) override
 Enable/Disable DTR protocol. More...
 
int flush () override
 Flushes the internal buffer. More...
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 ~DeviceDriver () override=default
 Destructor. More...
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver. More...
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others. More...
 
- Public Member Functions inherited from yarp::os::IConfig
virtual ~IConfig ()
 Destructor. More...
 
virtual bool configure (Searchable &config)
 Change online parameters. More...
 
- Public Member Functions inherited from yarp::dev::ISerialDevice
virtual ~ISerialDevice ()
 

Detailed Description

serialport: A basic Serial Communications Link (RS232, USB).

Definition at line 78 of file SerialDeviceDriver.h.

Constructor & Destructor Documentation

◆ SerialDeviceDriver()

SerialDeviceDriver::SerialDeviceDriver ( )

Definition at line 30 of file SerialDeviceDriver.cpp.

◆ ~SerialDeviceDriver()

SerialDeviceDriver::~SerialDeviceDriver ( )
virtual

Definition at line 37 of file SerialDeviceDriver.cpp.

Member Function Documentation

◆ close()

bool SerialDeviceDriver::close ( )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 103 of file SerialDeviceDriver.cpp.

◆ flush()

int SerialDeviceDriver::flush ( )
overridevirtual

Flushes the internal buffer.

Returns
- the number of flushed characters.

Implements yarp::dev::ISerialDevice.

Definition at line 204 of file SerialDeviceDriver.cpp.

◆ open() [1/2]

bool SerialDeviceDriver::open ( SerialDeviceDriverSettings config)

Configures the device.

Parameters
Theserial device configuration object
Returns
true on success

Definition at line 41 of file SerialDeviceDriver.cpp.

◆ open() [2/2]

bool SerialDeviceDriver::open ( yarp::os::Searchable config)
overridevirtual

Open the DeviceDriver.

Parameters
configis a list of parameters for the device. Which parameters are effective for your device can vary. See device invocation examples. If there is no example for your device, you can run the "yarpdev" program with the verbose flag set to probe what parameters the device is checking. If that fails too, you'll need to read the source code (please nag one of the yarp developers to add documentation for your device).
Returns
true/false upon success/failure

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 68 of file SerialDeviceDriver.cpp.

◆ receive()

bool SerialDeviceDriver::receive ( Bottle msg)
overridevirtual

Gets the existing chars in the receive queue.

Parameters
msg- the received string
Returns
- true on success; false if no messages available

Implements yarp::dev::ISerialDevice.

Definition at line 268 of file SerialDeviceDriver.cpp.

◆ receiveBytes()

int SerialDeviceDriver::receiveBytes ( unsigned char *  bytes,
const int  size 
)
overridevirtual

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

The array is NOT null terminated.

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

Implements yarp::dev::ISerialDevice.

Definition at line 219 of file SerialDeviceDriver.cpp.

◆ receiveChar()

int SerialDeviceDriver::receiveChar ( char &  chr)
overridevirtual

Gets one single char from the receive queue.

Parameters
chr- the received char.
Returns
- 0 if no chars are received; 1 if one char is received.

Implements yarp::dev::ISerialDevice.

Definition at line 182 of file SerialDeviceDriver.cpp.

◆ receiveLine()

int SerialDeviceDriver::receiveLine ( char *  line,
const int  MaxLineLength 
)
overridevirtual

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
line- a previously allocated buffer where the received line is stored.
MaxLineLength- the 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.

Implements yarp::dev::ISerialDevice.

Definition at line 240 of file SerialDeviceDriver.cpp.

◆ send() [1/2]

bool SerialDeviceDriver::send ( char *  msg,
size_t  size 
)
overridevirtual

Implements yarp::dev::ISerialDevice.

Definition at line 155 of file SerialDeviceDriver.cpp.

◆ send() [2/2]

bool SerialDeviceDriver::send ( const Bottle msg)
overridevirtual

Sends a string of chars to the serial communications channel.

Parameters
msgthe string to send
Returns
true on success

Implements yarp::dev::ISerialDevice.

Definition at line 118 of file SerialDeviceDriver.cpp.

◆ setDTR()

bool SerialDeviceDriver::setDTR ( bool  value)
overridevirtual

Enable/Disable DTR protocol.

Parameters
enableEnable/Disable DTR protocol
Returns
true on success

Implements yarp::dev::ISerialDevice.

Definition at line 108 of file SerialDeviceDriver.cpp.


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