YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeSerialPort Class Reference

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

#include <fake/fakeSerialPort/FakeSerialPort.h>

+ Inheritance diagram for FakeSerialPort:

Public Member Functions

 FakeSerialPort ()
 
virtual ~FakeSerialPort ()
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver.
 
bool close () override
 Close the DeviceDriver.
 
bool send (const Bottle &msg) override
 Sends a string of chars to the serial communications channel.
 
bool send (const char *msg, size_t size) override
 
bool receive (Bottle &msg) override
 Gets the existing chars in the receive queue.
 
int receiveChar (char &chr) override
 Gets one single char from the receive queue.
 
int receiveBytes (unsigned char *bytes, const int size) override
 Gets an array of bytes (unsigned char) with size <= 'size' parameter.
 
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.
 
bool setDTR (bool value) override
 Enable/Disable DTR protocol.
 
int flush () override
 Flushes the internal buffer.
 
- 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
 
virtual ~DeviceDriver ()
 
virtual std::string id () const
 Return the id assigned to the PolyDriver.
 
virtual void setId (const std::string &id)
 Set the id for this device.
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver.
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others.
 
- Public Member Functions inherited from yarp::dev::ISerialDevice
virtual ~ISerialDevice ()
 
- Public Member Functions inherited from FakeSerialPort_ParamsParser
 FakeSerialPort_ParamsParser ()
 
 ~FakeSerialPort_ParamsParser () override=default
 
bool parseParams (const yarp::os::Searchable &config) override
 Parse the DeviceDriver parameters.
 
std::string getDeviceClassName () const override
 Get the name of the DeviceDriver class.
 
std::string getDeviceName () const override
 Get the name of the device (i.e.
 
std::string getDocumentationOfDeviceParams () const override
 Get the documentation of the DeviceDriver's parameters.
 
std::vector< std::string > getListOfParams () const override
 Return a list of all params used by the device.
 
- Public Member Functions inherited from yarp::dev::IDeviceDriverParams
virtual ~IDeviceDriverParams ()
 

Additional Inherited Members

- Public Attributes inherited from FakeSerialPort_ParamsParser
const std::string m_device_classname = {"FakeSerialPort"}
 
const std::string m_device_name = {"fakeSerialPort"}
 
bool m_parser_is_strict = false
 
const parser_version_type m_parser_version = {}
 
const std::string m_comport_defaultValue = {"COM3"}
 
const std::string m_verbose_defaultValue = {"1"}
 
const std::string m_baudrate_defaultValue = {"9600"}
 
const std::string m_xonlim_defaultValue = {"0"}
 
const std::string m_xofflim_defaultValue = {"0"}
 
const std::string m_readmincharacters_defaultValue = {"1"}
 
const std::string m_readtimeoutmsec_defaultValue = {"100"}
 
const std::string m_paritymode_defaultValue = {"EVEN"}
 
const std::string m_ctsenb_defaultValue = {"0"}
 
const std::string m_rtsenb_defaultValue = {"0"}
 
const std::string m_xinenb_defaultValue = {"0"}
 
const std::string m_xoutenb_defaultValue = {"0"}
 
const std::string m_modem_defaultValue = {"0"}
 
const std::string m_rcvenb_defaultValue = {"0"}
 
const std::string m_dsrenb_defaultValue = {"0"}
 
const std::string m_dtrdisable_defaultValue = {"0"}
 
const std::string m_databits_defaultValue = {"7"}
 
const std::string m_stopbits_defaultValue = {"1"}
 
const std::string m_line_terminator_char1_defaultValue = {"'\r'"}
 
const std::string m_line_terminator_char2_defaultValue = {"'\n'"}
 
std::string m_comport = {"COM3"}
 
int m_verbose = {1}
 
int m_baudrate = {9600}
 
int m_xonlim = {0}
 
int m_xofflim = {0}
 
int m_readmincharacters = {1}
 
int m_readtimeoutmsec = {100}
 
std::string m_paritymode = {"EVEN"}
 
int m_ctsenb = {0}
 
int m_rtsenb = {0}
 
int m_xinenb = {0}
 
int m_xoutenb = {0}
 
int m_modem = {0}
 
int m_rcvenb = {0}
 
int m_dsrenb = {0}
 
int m_dtrdisable = {0}
 
int m_databits = {7}
 
int m_stopbits = {1}
 
char m_line_terminator_char1 = {'\r'}
 
char m_line_terminator_char2 = {'\n'}
 

Detailed Description

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

Parameters required by this device are shown in class: FakeSerialPort_ParamsParser Beware: all parameters parsed by fakeSerialPort are actually ignored because it is a fake device which does not connect to any real hardware.

Definition at line 28 of file FakeSerialPort.h.

Constructor & Destructor Documentation

◆ FakeSerialPort()

FakeSerialPort::FakeSerialPort ( )

Definition at line 21 of file FakeSerialPort.cpp.

◆ ~FakeSerialPort()

FakeSerialPort::~FakeSerialPort ( )
virtual

Definition at line 24 of file FakeSerialPort.cpp.

Member Function Documentation

◆ close()

bool FakeSerialPort::close ( )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 36 of file FakeSerialPort.cpp.

◆ flush()

int FakeSerialPort::flush ( )
overridevirtual

Flushes the internal buffer.

Returns
the number of flushed characters.

Implements yarp::dev::ISerialDevice.

Definition at line 131 of file FakeSerialPort.cpp.

◆ open()

bool FakeSerialPort::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 29 of file FakeSerialPort.cpp.

◆ receive()

bool FakeSerialPort::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 171 of file FakeSerialPort.cpp.

◆ receiveBytes()

int FakeSerialPort::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 136 of file FakeSerialPort.cpp.

◆ receiveChar()

int FakeSerialPort::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 110 of file FakeSerialPort.cpp.

◆ receiveLine()

int FakeSerialPort::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 143 of file FakeSerialPort.cpp.

◆ send() [1/2]

bool FakeSerialPort::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 46 of file FakeSerialPort.cpp.

◆ send() [2/2]

bool FakeSerialPort::send ( const char msg,
size_t  size 
)
overridevirtual

Implements yarp::dev::ISerialDevice.

Definition at line 80 of file FakeSerialPort.cpp.

◆ setDTR()

bool FakeSerialPort::setDTR ( bool  enable)
overridevirtual

Enable/Disable DTR protocol.

Parameters
enableEnable/Disable DTR protocol
Returns
true on success

Implements yarp::dev::ISerialDevice.

Definition at line 41 of file FakeSerialPort.cpp.


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