YARP
Yet Another Robot Platform

serial: Export a serial sensor. More...

#include <ServerSerial/ServerSerial.h>

+ Inheritance diagram for ServerSerial:

Public Member Functions

 ServerSerial ()=default
 
 ServerSerial (const ServerSerial &)=delete
 
 ServerSerial (ServerSerial &&)=delete
 
ServerSerialoperator= (const ServerSerial &)=delete
 
ServerSerialoperator= (ServerSerial &&)=delete
 
 ~ServerSerial () override
 
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
 DeviceDriver ()
 
 DeviceDriver (const DeviceDriver &other)=delete
 
 DeviceDriver (DeviceDriver &&other) noexcept=delete
 
DeviceDriveroperator= (const DeviceDriver &other)=delete
 
DeviceDriveroperator= (DeviceDriver &&other) noexcept=delete
 
 ~DeviceDriver () override
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver. More...
 
bool close () override
 Close the DeviceDriver. More...
 
virtual std::string id () const
 Return the id assigned to the PolyDriver. More...
 
virtual void setId (const std::string &id)
 Set the id for this device. 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 open (Searchable &config)
 Initialize the object. More...
 
virtual bool close ()
 Shut the object down. More...
 
virtual bool configure (Searchable &config)
 Change online parameters. More...
 
- Public Member Functions inherited from yarp::dev::ISerialDevice
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

serial: 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 68 of file ServerSerial.h.

Constructor & Destructor Documentation

◆ ServerSerial() [1/3]

ServerSerial::ServerSerial ( )
default

◆ ServerSerial() [2/3]

ServerSerial::ServerSerial ( const ServerSerial )
delete

◆ ServerSerial() [3/3]

ServerSerial::ServerSerial ( ServerSerial &&  )
delete

◆ ~ServerSerial()

ServerSerial::~ServerSerial ( )
override

Definition at line 17 of file ServerSerial.cpp.

Member Function Documentation

◆ close()

bool ServerSerial::close ( )
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 107 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 67 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 103 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 111 of file ServerSerial.cpp.

◆ operator=() [1/2]

ServerSerial & ServerSerial::operator= ( const ServerSerial )
delete

◆ operator=() [2/2]

ServerSerial & ServerSerial::operator= ( ServerSerial &&  )
delete

◆ receive()

bool ServerSerial::receive ( Bottle msg)
overridevirtual

Gets the existing chars in the receive queue.

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

Implements yarp::dev::ISerialDevice.

Definition at line 48 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
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.

Implements yarp::dev::ISerialDevice.

Definition at line 94 of file ServerSerial.cpp.

◆ receiveChar()

int ServerSerial::receiveChar ( char &  chr)
overridevirtual

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.

Implements yarp::dev::ISerialDevice.

Definition at line 58 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
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.

Implements yarp::dev::ISerialDevice.

Definition at line 85 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 173 of file ServerSerial.cpp.

◆ send() [1/2]

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

Implements yarp::dev::ISerialDevice.

Definition at line 35 of file ServerSerial.cpp.

◆ send() [2/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 22 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 76 of file ServerSerial.cpp.


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