serial communication class More...
#include <serial.hpp>
Public Member Functions | |
| Serial (const char *portname, const int baudrate) | |
| serial communication setting | |
| ~Serial () | |
| port closing | |
| void | write (const uint8_t *buffer, const size_t len) |
| write data via serial communication | |
| ssize_t | read (uint8_t *buf, const size_t len) |
| read data via serial communication | |
| ssize_t | read (uint8_t *buf, const size_t len, const std::chrono::duration< long, std::ratio< 1, 1000 > > timeout) |
| read data via serial communication, with timeout | |
| ssize_t | read_until (uint8_t *buf, const size_t len, const char end_char, std::chrono::duration< long, std::ratio< 1, 1000 > > timeout) |
| read data until a terminating character is received, with timeout | |
| void | setConfig (const int _baudrate) |
| configure serial communication settings | |
| void | setTermios () |
| set termios settings | |
| void | getTermios () |
| get termios settings | |
| void | flush () |
| flush buffer | |
Public Attributes | |
| int | fd |
serial communication class
|
explicit |
serial communication setting
| portname | port name of serial device |
| baudrate | baudrate of serial communication |
settings such as port opening and communication speed
| serial::Serial::~Serial | ( | ) |
port closing
| void serial::Serial::flush | ( | ) |
flush buffer
| void serial::Serial::getTermios | ( | ) |
get termios settings
get termios settings and store in tty
| ssize_t serial::Serial::read | ( | uint8_t * | buf, |
| const size_t | len | ||
| ) |
read data via serial communication
| buf | valiable to store the reading data |
| len | bytes of reading data |
| ssize_t serial::Serial::read | ( | uint8_t * | buf, |
| const size_t | len, | ||
| const std::chrono::duration< long, std::ratio< 1, 1000 > > | timeout | ||
| ) |
read data via serial communication, with timeout
| buf | valiable to store the reading data |
| len | bytes of reading data |
| timeout | timeout time |
wait until the specified number of bytes is received. However, after the specified time has elapsed, it times out.
| ssize_t serial::Serial::read_until | ( | uint8_t * | buf, |
| const size_t | len, | ||
| const char | end_char, | ||
| std::chrono::duration< long, std::ratio< 1, 1000 > > | timeout | ||
| ) |
read data until a terminating character is received, with timeout
| buf | valiable to store the reading data |
| len | bytes of reading data |
| end_char | character indicating the end of data |
| timeout | timeout time |
wait until the specified character is received. However, after the specified time has elapsed, it times out.
| void serial::Serial::setConfig | ( | const int | _baudrate | ) |
configure serial communication settings
| _baudrate | baudrate of serial communication |
settings such as baudrate, cflag, iflag and oflag
| void serial::Serial::setTermios | ( | ) |
set termios settings
configure settings stored in tty
| void serial::Serial::write | ( | const uint8_t * | buffer, |
| const size_t | len | ||
| ) |
write data via serial communication
| buf | writing data |
| len | length of buf |
write only len of data in buf
| int serial::Serial::fd |