| 2030 | } |
| 2031 | |
| 2032 | inline |
| 2033 | void |
| 2034 | SerialPort::Implementation::SetDefaultLinuxSpecificModes() |
| 2035 | { |
| 2036 | // Make sure that the serial port is open. |
| 2037 | if (not this->IsOpen()) |
| 2038 | { |
| 2039 | throw NotOpen(ERR_MSG_PORT_NOT_OPEN) ; |
| 2040 | } |
| 2041 | |
| 2042 | // Get the current serial port settings. |
| 2043 | termios port_settings {} ; |
| 2044 | std::memset(&port_settings, 0, sizeof(port_settings)) ; |
| 2045 | |
| 2046 | if (tcgetattr(this->mFileDescriptor, |
| 2047 | &port_settings) < 0) |
| 2048 | { |
| 2049 | throw std::runtime_error(std::strerror(errno)) ; |
| 2050 | } |
| 2051 | |
| 2052 | // @NOTE - termios.c_line is not a standard element of the termios |
| 2053 | // structure, (as per the Single Unix Specification 3). |
| 2054 | port_settings.c_line = '\0' ; |
| 2055 | |
| 2056 | // Apply the modified settings. |
| 2057 | if (tcsetattr(this->mFileDescriptor, |
| 2058 | TCSANOW, |
| 2059 | &port_settings) < 0) |
| 2060 | { |
| 2061 | throw OpenFailed(std::strerror(errno)) ; |
| 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | inline |
| 2066 | void |
nothing calls this directly
no test coverage detected