MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / applyModbusParity

Function applyModbusParity

app/src/Misc/CLI.cpp:842–860  ·  view source on GitHub ↗

* @brief Applies the Modbus parity option to the active Modbus driver. */

Source from the content-addressed store, hash-verified

840 * @brief Applies the Modbus parity option to the active Modbus driver.
841 */
842static 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.

Callers 1

Calls 4

cendMethod · 0.80
modbusMethod · 0.80
setParityIndexMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected