MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / close

Method close

sources/led-drivers/serial/ProviderSerial.cpp:136–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136int ProviderSerial::close()
137{
138 int retval = 0;
139
140 _isDeviceReady = false;
141
142 if (_serialPort != nullptr && _serialPort->isOpen())
143 {
144 if (_serialPort->flush())
145 {
146 Debug(_log, "Flush was successful");
147 }
148
149
150 if (_espHandshake)
151 {
152 QTimer::singleShot(200, this, [this]() { if (_serialPort->isOpen()) EspTools::goingSleep(_serialPort); });
153 EspTools::goingSleep(_serialPort);
154
155 for (int i = 0; i < 6 && _serialPort->isOpen(); i++)
156 {
157 if (_serialPort->waitForReadyRead(100) && waitForExitStats())
158 break;
159 }
160 }
161
162 _serialPort->close();
163
164 Debug(_log, "Serial port is closed: %s", QSTRING_CSTR(_deviceName));
165
166 }
167 return retval;
168}
169
170bool ProviderSerial::powerOff()
171{

Callers 2

setInErrorMethod · 0.95
~ProviderSerialMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected