MCPcopy Create free account
hub / github.com/crayzeewulf/libserial / SetDefaultLinuxSpecificModes

Method SetDefaultLinuxSpecificModes

src/SerialPort.cpp:2032–2063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

NotOpenClass · 0.85
OpenFailedClass · 0.85
IsOpenMethod · 0.45

Tested by

no test coverage detected