* @brief Closes the slcan channel and the serial port. */
| 203 | * @brief Closes the slcan channel and the serial port. |
| 204 | */ |
| 205 | void IO::Drivers::SlcanBackend::close() |
| 206 | { |
| 207 | setState(QCanBusDevice::ClosingState); |
| 208 | |
| 209 | if (m_port) { |
| 210 | if (m_port->isOpen()) { |
| 211 | (void)sendCommand(QByteArrayLiteral("C\r")); |
| 212 | m_port->close(); |
| 213 | } |
| 214 | |
| 215 | m_port->deleteLater(); |
| 216 | m_port = nullptr; |
| 217 | } |
| 218 | |
| 219 | m_rxBuffer.clear(); |
| 220 | setState(QCanBusDevice::UnconnectedState); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * @brief Encodes a QCanBusFrame as a LAWICEL command and writes it to the port. |