YARP
Yet Another Robot Platform
yarp::dev::ServerSerial Class Reference

Export a serial sensor. More...

#include <ServerSerial/ServerSerial.h>

+ Inheritance diagram for yarp::dev::ServerSerial:

Detailed Description

Export a serial sensor.

The network interface is composed by two ports. The input port accepts bottles and sends their contents as text to the serial port. The output port streams out whatever information it gets in the serial port as text bottles.

Definition at line 75 of file ServerSerial.h.

Public Member Functions

 ServerSerial ()
 Constructor. More...
 
virtual ~ServerSerial ()
 
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 &c) override
 Gets one single char from the receive queue. More...
 
int flush () override
 Flushes the internal buffer. 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...
 
int receiveBytes (unsigned char *bytes, const int size) override
 Gets an array of bytes (unsigned char) with size <= 'size' parameter. More...
 
bool setDTR (bool enable) override
 Enable/Disable DTR protocol. More...
 
virtual bool open ()
 Default open() method. More...
 
bool close () override
 Close the device driver by deallocating all resources and closing ports. More...
 
bool open (Searchable &prop) override
 Open the device driver. More...
 
void run () override
 The thread main loop deals with writing on ports here. More...
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
virtual ~DeviceDriver ()
 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 ()
 

Constructor & Destructor Documentation

◆ ServerSerial()

ServerSerial::ServerSerial ( )

Constructor.

Definition at line 23 of file ServerSerial.cpp.

◆ ~ServerSerial()

ServerSerial::~ServerSerial ( )
virtual

Definition at line 31 of file ServerSerial.cpp.

Member Function Documentation

◆ close()

bool ServerSerial::close ( void  )
overridevirtual

Close the device driver by deallocating all resources and closing ports.

Returns
true if successful or false otherwise.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 119 of file ServerSerial.cpp.

◆ flush()

int ServerSerial::flush ( )
overridevirtual

Flushes the internal buffer.

Returns
- the number of flushed characters.

Implements yarp::dev::ISerialDevice.

Definition at line 79 of file ServerSerial.cpp.

◆ open() [1/2]

bool ServerSerial::open ( )
virtual

Default open() method.

Returns
always false since initialization requires certain parameters.

Definition at line 115 of file ServerSerial.cpp.

◆ open() [2/2]

bool ServerSerial::open ( Searchable prop)
overridevirtual

Open the device driver.

Parameters
propis a Searchable object that contains the parameters to use. Allowed parameters are:
  • verbose or v to print diagnostic information while running,
  • name to specify the prefix of the port names and all parameters requied by the wrapped device driver.
Returns
true iff the object could be configured.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 123 of file ServerSerial.cpp.

◆ receive()

bool ServerSerial::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 60 of file ServerSerial.cpp.

◆ receiveBytes()

int ServerSerial::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 106 of file ServerSerial.cpp.

◆ receiveChar()

int ServerSerial::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 70 of file ServerSerial.cpp.

◆ receiveLine()

int ServerSerial::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 '
''' chars, plus the buffer terminator '\0'). The function returns 0 if no chars are received.

Implements yarp::dev::ISerialDevice.

Definition at line 97 of file ServerSerial.cpp.

◆ run()

void ServerSerial::run ( )
overridevirtual

The thread main loop deals with writing on ports here.

Implements yarp::os::Thread.

Definition at line 184 of file ServerSerial.cpp.

◆ send() [1/2]

bool ServerSerial::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 36 of file ServerSerial.cpp.

◆ send() [2/2]

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

Implements yarp::dev::ISerialDevice.

Definition at line 48 of file ServerSerial.cpp.

◆ setDTR()

bool ServerSerial::setDTR ( bool  enable)
overridevirtual

Enable/Disable DTR protocol.

Parameters
enableEnable/Disable DTR protocol
Returns
true on success

Implements yarp::dev::ISerialDevice.

Definition at line 88 of file ServerSerial.cpp.


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