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

Method SetDefaultControlModes

src/SerialPort.cpp:2128–2158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2126 }
2127
2128 inline
2129 void
2130 SerialPort::Implementation::SetDefaultControlModes()
2131 {
2132 // Make sure that the serial port is open.
2133 if (not this->IsOpen())
2134 {
2135 throw NotOpen(ERR_MSG_PORT_NOT_OPEN) ;
2136 }
2137
2138 // Get the current serial port settings.
2139 termios port_settings {} ;
2140 std::memset(&port_settings, 0, sizeof(port_settings)) ;
2141
2142 if (tcgetattr(this->mFileDescriptor,
2143 &port_settings) < 0)
2144 {
2145 throw std::runtime_error(std::strerror(errno)) ;
2146 }
2147
2148 // Enable the receiver (CREAD) and ignore modem control lines (CLOCAL).
2149 port_settings.c_cflag |= CREAD | CLOCAL ; // NOLINT (hicpp-signed-bitwise)
2150
2151 // Apply the modified settings.
2152 if (tcsetattr(this->mFileDescriptor,
2153 TCSANOW,
2154 &port_settings) < 0)
2155 {
2156 throw OpenFailed(std::strerror(errno)) ;
2157 }
2158 }
2159
2160 inline
2161 void

Callers

nothing calls this directly

Calls 3

NotOpenClass · 0.85
OpenFailedClass · 0.85
IsOpenMethod · 0.45

Tested by

no test coverage detected