* @brief Applies the Modbus data-bits option to the active Modbus driver. */
| 863 | * @brief Applies the Modbus data-bits option to the active Modbus driver. |
| 864 | */ |
| 865 | static void applyModbusDataBits(const QString& dataBits) |
| 866 | { |
| 867 | static const QHash<QString, quint8> kDataBits = { |
| 868 | {QStringLiteral("5"), 0}, |
| 869 | {QStringLiteral("6"), 1}, |
| 870 | {QStringLiteral("7"), 2}, |
| 871 | {QStringLiteral("8"), 3}, |
| 872 | }; |
| 873 | |
| 874 | const auto it = kDataBits.constFind(dataBits); |
| 875 | if (it == kDataBits.cend()) { |
| 876 | qWarning() << "Invalid ModBus data bits (5/6/7/8):" << dataBits; |
| 877 | IO::ConnectionManager::instance().modbus()->setDataBitsIndex(3); |
| 878 | return; |
| 879 | } |
| 880 | |
| 881 | IO::ConnectionManager::instance().modbus()->setDataBitsIndex(it.value()); |
| 882 | } |
| 883 | |
| 884 | /** |
| 885 | * @brief Applies the Modbus stop-bits option to the active Modbus driver. |
no test coverage detected