* @brief Changes the port index value, later used by openSerialPort(). */
| 526 | * @brief Changes the port index value, later used by openSerialPort(). |
| 527 | */ |
| 528 | void IO::Drivers::UART::setPortIndex(const quint8 portIndex) |
| 529 | { |
| 530 | if (m_deviceNames.isEmpty()) |
| 531 | refreshSerialDevices(); |
| 532 | |
| 533 | if (portIndex < portList().count()) |
| 534 | m_portIndex = portIndex; |
| 535 | else |
| 536 | m_portIndex = 0; |
| 537 | |
| 538 | const auto name = portList().at(m_portIndex); |
| 539 | if (!name.isEmpty() && m_portIndex > 0) |
| 540 | m_settings.setValue("IO_Serial_SelectedDevice", name); |
| 541 | |
| 542 | Q_EMIT portIndexChanged(); |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * @brief Registers a custom serial device by path. |