* @brief Closes the serial port and clears its signal/slot connections. */
| 118 | * @brief Closes the serial port and clears its signal/slot connections. |
| 119 | */ |
| 120 | void IO::Drivers::UART::close() |
| 121 | { |
| 122 | if (port() != nullptr) { |
| 123 | disconnect(port(), &QSerialPort::errorOccurred, this, &IO::Drivers::UART::handleError); |
| 124 | disconnect(port(), &QIODevice::readyRead, this, &IO::Drivers::UART::onReadyRead); |
| 125 | |
| 126 | if (dtrEnabled()) |
| 127 | port()->setDataTerminalReady(false); |
| 128 | |
| 129 | port()->close(); |
| 130 | port()->deleteLater(); |
| 131 | } |
| 132 | |
| 133 | m_port = nullptr; |
| 134 | m_usingCustomSerialPort = false; |
| 135 | |
| 136 | Q_EMIT portChanged(); |
| 137 | Q_EMIT availablePortsChanged(); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * @brief Returns true when the serial port is open. |