MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / handleError

Method handleError

app/src/IO/Drivers/UART.cpp:778–804  ·  view source on GitHub ↗

* @brief Handles a serial port error by disconnecting and showing a message box. */

Source from the content-addressed store, hash-verified

776 * @brief Handles a serial port error by disconnecting and showing a message box.
777 */
778void IO::Drivers::UART::handleError(QSerialPort::SerialPortError error)
779{
780 QMutexLocker locker(&m_errorHandlerMutex);
781
782 auto serialPort = port();
783 if (serialPort && !serialPort->isOpen())
784 return;
785
786 if (!isOpen())
787 return;
788
789 if (error != QSerialPort::NoError) {
790 if (m_usingCustomSerialPort) {
791 if (error == QSerialPort::UnsupportedOperationError || error == QSerialPort::ResourceError)
792 return;
793 }
794
795 ConnectionManager::instance().disconnectDevice(this);
796
797 if (!m_autoReconnect || error != QSerialPort::ResourceError) {
798 const auto name = serialPort ? serialPort->portName() : tr("Unknown");
799 Misc::Utilities::showMessageBox(tr("Critical error on serial port \"%1\"").arg(name),
800 m_errorDescriptions.value(error, tr("Unknown error")),
801 QMessageBox::Critical);
802 }
803 }
804}
805
806/**
807 * @brief Reads all the data from the serial port.

Callers

nothing calls this directly

Calls 3

disconnectDeviceMethod · 0.80
isOpenMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected