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

Function applyModbusStopBits

app/src/Misc/CLI.cpp:887–903  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

885 * @brief Applies the Modbus stop-bits option to the active Modbus driver.
886 */
887static void applyModbusStopBits(const QString& stopBits)
888{
889 static const QHash<QString, quint8> kStopBits = {
890 { QStringLiteral("1"), 0},
891 {QStringLiteral("1.5"), 1},
892 { QStringLiteral("2"), 2},
893 };
894
895 const auto it = kStopBits.constFind(stopBits);
896 if (it == kStopBits.cend()) {
897 qWarning() << "Invalid ModBus stop bits (1/1.5/2):" << stopBits;
898 IO::ConnectionManager::instance().modbus()->setStopBitsIndex(0);
899 return;
900 }
901
902 IO::ConnectionManager::instance().modbus()->setStopBitsIndex(it.value());
903}
904
905/**
906 * @brief Applies the Modbus slave option to the active Modbus driver.

Callers 1

Calls 4

cendMethod · 0.80
modbusMethod · 0.80
setStopBitsIndexMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected