* @brief Applies the Modbus parity option to the active Modbus driver. */
| 840 | * @brief Applies the Modbus parity option to the active Modbus driver. |
| 841 | */ |
| 842 | static void applyModbusParity(const QString& parity) |
| 843 | { |
| 844 | static const QHash<QString, quint8> kParity = { |
| 845 | { QStringLiteral("none"), 0}, |
| 846 | { QStringLiteral("even"), 1}, |
| 847 | { QStringLiteral("odd"), 2}, |
| 848 | {QStringLiteral("space"), 3}, |
| 849 | { QStringLiteral("mark"), 4}, |
| 850 | }; |
| 851 | |
| 852 | const auto it = kParity.constFind(parity); |
| 853 | if (it == kParity.cend()) { |
| 854 | qWarning() << "Invalid ModBus parity (none/even/odd/space/mark):" << parity; |
| 855 | IO::ConnectionManager::instance().modbus()->setParityIndex(0); |
| 856 | return; |
| 857 | } |
| 858 | |
| 859 | IO::ConnectionManager::instance().modbus()->setParityIndex(it.value()); |
| 860 | } |
| 861 | |
| 862 | /** |
| 863 | * @brief Applies the Modbus data-bits option to the active Modbus driver. |
no test coverage detected