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

Function applyModbusSlave

app/src/Misc/CLI.cpp:908–921  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

906 * @brief Applies the Modbus slave option to the active Modbus driver.
907 */
908static void applyModbusSlave(const QCommandLineParser& parser, const QCommandLineOption& opt)
909{
910 if (!parser.isSet(opt))
911 return;
912
913 bool ok = false;
914 unsigned int slave_val = parser.value(opt).toUInt(&ok);
915 if (!ok || slave_val < 1 || slave_val > 247) {
916 qWarning() << "Invalid ModBus slave address (1-247):" << parser.value(opt);
917 return;
918 }
919
920 IO::ConnectionManager::instance().modbus()->setSlaveAddress(static_cast<quint8>(slave_val));
921}
922
923/**
924 * @brief Applies the Modbus poll-interval option to the active Modbus driver.

Callers 2

Calls 3

modbusMethod · 0.80
valueMethod · 0.45
setSlaveAddressMethod · 0.45

Tested by

no test coverage detected