libtasks Documentation
1.6
|
A class that allows to read and write from/to terminal devices. More...
#include <term.h>
Public Member Functions | |
term () | |
Contruct an object. More... | |
term (int fd) | |
Contruct an object by providing a terminal file descriptor. More... | |
void | open (std::string port, speed_t baudrate=B9600, charsize_t charsize=charsize_t::_8, parity_t parity=parity_t::NONE, stopbits_t stopbits=stopbits_t::_1) |
Open a terminal device. More... | |
void | open (std::string port, speed_t baudrate=B9600, termmode_t mode=termmode_t::_8N1) |
Open a terminal device. More... | |
struct termios | options () |
Access terminal options. More... | |
void | set_options (struct termios &opts) |
Set terminal options. More... | |
speed_t | baudrate () const |
Access the baudrate. More... | |
void | baudrate (speed_t br) |
Set the baudrate. More... | |
void | close () |
Close the terminal. More... | |
std::streamsize | write (const char *data, std::size_t len) |
Write data to the terminal. More... | |
std::streamsize | read (char *data, std::size_t len) |
Read data from the terminal. More... | |
![]() | |
io_base () | |
io_base (int fd) | |
virtual | ~io_base () |
int | fd () const |
Additional Inherited Members | |
![]() | |
int | m_fd = -1 |
A class that allows to read and write from/to terminal devices.
This is a wrapper class around the POSIX terminal interface. Not all capabilities have been implemented. You can use the options() method to set unsupported options like flow control etc for example.
|
inline |
speed_t tasks::serial::term::baudrate | ( | ) | const |
Access the baudrate.
void tasks::serial::term::baudrate | ( | speed_t | br | ) |
Set the baudrate.
|
virtual |
void tasks::serial::term::open | ( | std::string | port, |
speed_t | baudrate = B9600 , |
||
charsize_t | charsize = charsize_t::_8 , |
||
parity_t | parity = parity_t::NONE , |
||
stopbits_t | stopbits = stopbits_t::_1 |
||
) |
Open a terminal device.
port | The device port (eg: /dev/ttyUSB0) |
baudrate | The baudrate (default: 9600) |
charsize | The size of a character (default: chrarsize_t::CS8 for 8 bits) |
parity | The parity (default: parity_t::NONE) |
stopbits | The number of stopbits (default: stopbits_t::SB1) |
Definition at line 40 of file term.cpp.
void tasks::serial::term::open | ( | std::string | port, |
speed_t | baudrate = B9600 , |
||
termmode_t | mode = termmode_t::_8N1 |
||
) |
Open a terminal device.
port | The device port (eg: /dev/ttyUSB0) |
baudrate | The baudrate (default: 9600) |
mode | The mode the device should be opened with (default: termmode_t::_8N1 for 8N1 mode) |
Definition at line 111 of file term.cpp.
struct termios tasks::serial::term::options | ( | ) |
std::streamsize tasks::serial::term::read | ( | char * | data, |
std::size_t | len | ||
) |
void tasks::serial::term::set_options | ( | struct termios & | opts | ) |
std::streamsize tasks::serial::term::write | ( | const char * | data, |
std::size_t | len | ||
) |