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

Function applyModbusDataBits

app/src/Misc/CLI.cpp:865–882  ·  view source on GitHub ↗

* @brief Applies the Modbus data-bits option to the active Modbus driver. */

Source from the content-addressed store, hash-verified

863 * @brief Applies the Modbus data-bits option to the active Modbus driver.
864 */
865static 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.

Callers 1

Calls 4

cendMethod · 0.80
modbusMethod · 0.80
setDataBitsIndexMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected