Thunderbots Project
Loading...
Searching...
No Matches
BoostUartCommunication Class Reference
Inheritance diagram for BoostUartCommunication:
Collaboration diagram for BoostUartCommunication:

Public Member Functions

 BoostUartCommunication (int baud_rate, std::string device_serial_port)
 
 BoostUartCommunication (const BoostUartCommunication &)=delete
 
BoostUartCommunicationoperator= (const BoostUartCommunication &)=delete
 
bool operator<< (const std::vector< unsigned char > &write_val)
 
bool serialWrite (const std::vector< unsigned char > &write_val) override
 
std::vector< unsigned char > serialRead (size_t num_read_bytes) override
 
bool flushSerialPort (FlushType flush_type) override
 
- Public Member Functions inherited from UartCommunication
 UartCommunication (const UartCommunication &)=delete
 
UartCommunicationoperator= (const UartCommunication &)=delete
 

Additional Inherited Members

- Public Types inherited from UartCommunication
enum  FlushType { flush_receive = TCIFLUSH , flush_send = TCOFLUSH , flush_both = TCIOFLUSH }
 

Constructor & Destructor Documentation

◆ BoostUartCommunication()

BoostUartCommunication ( int  baud_rate,
std::string  device_serial_port 
)

constructs and opens a serial connection with the given device port settings used: 8 bit data, No flow control, No parity, 1 stop bit

Parameters
baud_ratethe desired baud rate of the connection
device_serial_portthe serial port that we want to communicate with
Exceptions
boost::exceptionif port could not be opened

Member Function Documentation

◆ flushSerialPort()

bool flushSerialPort ( FlushType  flush_type)
overridevirtual

Flushes serial port data

Parameters
flush_typeenum that sets the data to be flushed (read, write, or both)
Returns
true upon success, false otherwise

Implements UartCommunication.

◆ operator<<()

bool operator<< ( const std::vector< unsigned char > &  write_val)

Stream output operator, writes to serial port, blocking thread

Parameters
write_val
Returns
true if succeeded, false otherwise
Exceptions
boost::exceptionupon error

◆ serialRead()

std::vector< unsigned char > serialRead ( size_t  num_read_bytes)
overridevirtual

Reads a given number of bytes from serial port until num_read_bytes is read or error occurs. Blocks current thread.

Parameters
num_read_bytesnumber of bytes that should be read
Returns
vector of size num_read_bytes with read data
Exceptions
boost:exceptionupon error during read

Implements UartCommunication.

◆ serialWrite()

bool serialWrite ( const std::vector< unsigned char > &  write_val)
overridevirtual

Writes into serial port. Blocks current thread.

Parameters
write_valbuffer that will be written to serial port
Returns
true upon success, false otherwise
Exceptions
boost::exceptionupon error during write

Implements UartCommunication.


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