11 #ifndef __STD_UART_HEADER
12 #define __STD_UART_HEADER
22 typedef int16_t size_type;
30 memset(&tio,0,
sizeof(tio));
33 tio.c_cflag=CS8|CREAD|CLOCAL;
38 bool init(std::string
const & name, uint
const & baud = 460800ul) {
39 tty_fd=::open(name.c_str(), O_RDWR | O_NONBLOCK | O_NOCTTY);
47 #define lazyswitch(X) else if(baud == X) {cfsetospeed(&tio, B##X);cfsetispeed(&tio, B##X);}
75 tcsetattr(tty_fd, TCSANOW, &tio);
84 avail = (
::read(tty_fd,&c,1) > 0);
88 size_type
write(
char const & data, uint8_t
const & len = 1) {
90 int sent =
::write(tty_fd, &data, len);
92 sent =
::write(tty_fd, &data, len);
118 for(uint
i = 0;
i < 10000; ++
i) {
142 #endif //__STD_UART_HEADER
~serial_class()
Definition: std_serial.hpp:26
#define GREEN
Definition: color.hpp:15
#define RED
Definition: color.hpp:13
#define GREENB
Definition: color.hpp:16
void set_tio()
Definition: std_serial.hpp:29
Definition: std_serial.hpp:21
serial_class()
Definition: std_serial.hpp:24
#define NONE
Definition: color.hpp:37
struct ustd::endl_class endl
size_type available()
Definition: std_serial.hpp:82
#define REDB
Definition: color.hpp:14
size_type write(char const &data, uint8_t const &len=1)
Definition: std_serial.hpp:88
void close()
Definition: std_serial.hpp:127
int wait()
Definition: std_serial.hpp:103
void flush()
Definition: std_serial.hpp:117
char read()
Definition: std_serial.hpp:110
bool init(std::string const &name, uint const &baud=460800ul)
Definition: std_serial.hpp:38