12 file_desc = open(device.c_str(), O_RDWR | O_NOCTTY);
16 struct termios options;
17 int code = tcgetattr(file_desc, &options);
21 options.c_cflag = CS8 | CLOCAL | CREAD;
22 options.c_iflag = IGNPAR;
25 options.c_cc[VMIN] = 0;
26 options.c_cc[VTIME] = timeout;
27 code = cfsetspeed(&options, baudrate);
31 code = tcsetattr(file_desc, TCSANOW, &options);
35 code = fcntl(file_desc, F_SETFL, 0);
37 throw USARTException(
"Fehler beim Aktivieren des blockierenden Modus'");
47 int code = close(file_desc);
56 int code = tcflush(file_desc, TCIFLUSH);
63 int code = tcflush(file_desc, TCOFLUSH);
70 int code = tcdrain(file_desc);
77 int bytes_avail, code;
80 code = ioctl(file_desc, FIONREAD, &bytes_avail);
83 std::string(__FUNCTION__) +
" failed: " + std::string(__FILE__) +
"#" + std::to_string(__LINE__) +
84 ", " + strerror(code) +
" (code " + std::to_string(code) +
")");
86 while(bytes_avail < len);
88 code = read(file_desc, buffer + offset, len);
91 std::string(__FUNCTION__) +
" failed: " + std::string(__FILE__) +
"#" + std::to_string(__LINE__) +
92 ", " + strerror(code) +
" (code " + std::to_string(code) +
" / " + std::to_string(len) +
")");
97 int code = write(file_desc, buffer + offset, len);
100 std::string(__FUNCTION__) +
" failed: " + std::string(__FILE__) +
"#" + std::to_string(__LINE__) +
101 ", " + strerror(code) +
" (code " + std::to_string(code) +
" / " + std::to_string(len) +
")");
116 this->baudrate = baudrate;
121 this->timeout = timeout;