* @brief Handles a serial port error by disconnecting and showing a message box. */
| 776 | * @brief Handles a serial port error by disconnecting and showing a message box. |
| 777 | */ |
| 778 | void 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. |
nothing calls this directly
no test coverage detected