11 file_desc = open(device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
15 struct termios options;
16 int code = tcgetattr(file_desc, &options);
20 options.c_cflag = CS8 | CLOCAL | CREAD;
21 options.c_iflag = IGNPAR;
24 options.c_cc[VMIN] = 0;
25 options.c_cc[VTIME] = timeout;
26 code = cfsetspeed(&options, baudrate);
30 code = tcsetattr(file_desc, TCSANOW, &options);
42 int code = close(file_desc);
51 int code = tcflush(file_desc, TCIFLUSH);
58 int code = tcflush(file_desc, TCOFLUSH);
65 int code = tcdrain(file_desc);
72 int n = read(file_desc, buffer + offset, len);
75 std::string(__FUNCTION__) +
" failed: " + std::string(__FILE__) +
"#" + std::to_string(__LINE__));
80 int n = write(file_desc, buffer + offset, len);
83 std::string(__FUNCTION__) +
" failed: " + std::string(__FILE__) +
"#" + std::to_string(__LINE__));
98 this->baudrate = baudrate;
103 this->timeout = timeout;