fixed typos and extended readme
parent
b673fed516
commit
78055fbdf5
|
|
@ -92,7 +92,7 @@ int ModbusRTUMaster::timeout()
|
||||||
return m_modbusRtuSerialMaster->timeout();
|
return m_modbusRtuSerialMaster->timeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ModbusRTUMaster::numberOfReties()
|
int ModbusRTUMaster::numberOfRetries()
|
||||||
{
|
{
|
||||||
return m_modbusRtuSerialMaster->numberOfRetries();
|
return m_modbusRtuSerialMaster->numberOfRetries();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public:
|
||||||
void setTimeout(int timeout);
|
void setTimeout(int timeout);
|
||||||
|
|
||||||
int timeout();
|
int timeout();
|
||||||
int numberOfReties();
|
int numberOfRetries();
|
||||||
|
|
||||||
QUuid readCoil(uint slaveAddress, uint registerAddress, uint size = 1);
|
QUuid readCoil(uint slaveAddress, uint registerAddress, uint size = 1);
|
||||||
QUuid readDiscreteInput(uint slaveAddress, uint registerAddress, uint size = 1);
|
QUuid readDiscreteInput(uint slaveAddress, uint registerAddress, uint size = 1);
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,62 @@
|
||||||
# Modbus Commander
|
# Modbus Commander
|
||||||
|
|
||||||
A nymea plugin to send Modbus commands.
|
A nymea integration plugin to send Modbus RTU or TCP requests.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Set up one Modbus RTU or TCP client first. Afterwards a register **thing** can be set-up
|
||||||
|
and during the setup process the modbus client can be selected.
|
||||||
|
|
||||||
## Supported Things
|
## Supported Things
|
||||||
|
|
||||||
* Modbus TCP client
|
* Modbus TCP client
|
||||||
* Gateway
|
* Modbus TCP interface
|
||||||
|
* IP Address and Port of the target device are requried.
|
||||||
* Modbus RTU client
|
* Modbus RTU client
|
||||||
* Gateway
|
* Modbus RTU interface
|
||||||
* Discovery setup
|
* All available serial ports will be discovered.
|
||||||
|
* Baudrate, data bits, stop bits and parity are required.
|
||||||
* Coil
|
* Coil
|
||||||
* Writes and reads a single Modbus Coil
|
* Writes and reads a single Modbus Coil
|
||||||
|
* Modbus device- and register address are required.
|
||||||
* Discrete input
|
* Discrete input
|
||||||
* Reads a single Modbus discrete input
|
* Reads a single Modbus discrete input
|
||||||
|
* Modbus device- and register address are required.
|
||||||
* Input register
|
* Input register
|
||||||
* Reads a single Modbus input register
|
* Reads a single Modbus input register
|
||||||
|
* Modbus device- and register address are required.
|
||||||
* Holding register
|
* Holding register
|
||||||
* Writes and reads a single Modbus holding register
|
* Writes and reads a single Modbus holding register
|
||||||
|
* Modbus device- and register address are required.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* The package 'nymea-plugin-modbuscommander' must be installed.
|
* The package 'nymea-plugin-modbuscommander' must be installed.
|
||||||
* For Modbus RTU a serial port must be available.
|
* For Modbus RTU, a serial port must be available.
|
||||||
|
* For Modbus TCP, the target deviecc must be in the same network.
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
### Plug-In Configuration
|
||||||
|
|
||||||
|
*Update interval*
|
||||||
|
|
||||||
|
Defines the interval for register polling in seconds.
|
||||||
|
Minimum and default value is 1 second.
|
||||||
|
|
||||||
|
### Modbus TCP & RTU Client Settings
|
||||||
|
|
||||||
|
*Timeout*
|
||||||
|
|
||||||
|
Default value is 100 ms, the minimum timeout is 10 ms.
|
||||||
|
The timeout is used by the Modbus client to determine how long it waits
|
||||||
|
for a response from the server. The request failes if the response
|
||||||
|
is not received within the given timeout.
|
||||||
|
|
||||||
|
*Number of retries*
|
||||||
|
|
||||||
|
Sets the number of retries a client will perform before a request fails.
|
||||||
|
The default value is set to 3.
|
||||||
|
|
||||||
## More
|
## More
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
|
|
||||||
if (thing->thingClassId() == modbusTCPClientThingClassId) {
|
if (thing->thingClassId() == modbusTCPClientThingClassId) {
|
||||||
|
|
||||||
QHostAddress hostAddress = QHostAddress(thing->paramValue(modbusTCPClientThingIpAddressParamTypeId).toString());
|
QHostAddress hostAddress = QHostAddress(thing->paramValue(modbusTCPClientThingIpAddressParamTypeId).toString());
|
||||||
uint port = thing->paramValue(modbusTCPClientThingPortParamTypeId).toUInt();
|
uint port = thing->paramValue(modbusTCPClientThingPortParamTypeId).toUInt();
|
||||||
uint numberOfRetries = thing->setting(modbusTCPClientSettingsNumberOfRetriesParamTypeId).toUInt();
|
uint numberOfRetries = thing->setting(modbusTCPClientSettingsNumberOfRetriesParamTypeId).toUInt();
|
||||||
|
|
@ -189,7 +190,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(dcModbusCommander()) << "Setting up TCP client";
|
qCDebug(dcModbusCommander()) << "Setting up TCP client" << thing->name();
|
||||||
qCDebug(dcModbusCommander()) << " address:" << hostAddress.toString();
|
qCDebug(dcModbusCommander()) << " address:" << hostAddress.toString();
|
||||||
qCDebug(dcModbusCommander()) << " port:" << port;
|
qCDebug(dcModbusCommander()) << " port:" << port;
|
||||||
qCDebug(dcModbusCommander()) << " number of retries:" << numberOfRetries;
|
qCDebug(dcModbusCommander()) << " number of retries:" << numberOfRetries;
|
||||||
|
|
@ -211,7 +212,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
|
||||||
});
|
});
|
||||||
connect(thing, &Thing::settingChanged, thing, [thing, modbusTCPMaster] (const ParamTypeId ¶mTypeId, const QVariant &value) {
|
connect(thing, &Thing::settingChanged, thing, [thing, modbusTCPMaster] (const ParamTypeId ¶mTypeId, const QVariant &value) {
|
||||||
if (paramTypeId == modbusTCPClientSettingsNumberOfRetriesParamTypeId) {
|
if (paramTypeId == modbusTCPClientSettingsNumberOfRetriesParamTypeId) {
|
||||||
qCDebug(dcModbusCommander()) << "Set number of reties" << thing->name() << value.toUInt();
|
qCDebug(dcModbusCommander()) << "Set number of retries" << thing->name() << value.toUInt();
|
||||||
modbusTCPMaster->setNumberOfRetries(value.toUInt());
|
modbusTCPMaster->setNumberOfRetries(value.toUInt());
|
||||||
} else if (paramTypeId == modbusTCPClientSettingsTimeoutParamTypeId) {
|
} else if (paramTypeId == modbusTCPClientSettingsTimeoutParamTypeId) {
|
||||||
qCDebug(dcModbusCommander()) << "Set timeout " << thing->name() << value.toUInt();
|
qCDebug(dcModbusCommander()) << "Set timeout " << thing->name() << value.toUInt();
|
||||||
|
|
@ -237,7 +238,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
|
||||||
} else if (parityString.contains("Odd")) {
|
} else if (parityString.contains("Odd")) {
|
||||||
parity = QSerialPort::Parity::OddParity;
|
parity = QSerialPort::Parity::OddParity;
|
||||||
}
|
}
|
||||||
qCDebug(dcModbusCommander()) << "Setting up RTU client";
|
qCDebug(dcModbusCommander()) << "Setting up RTU client" << thing->name();
|
||||||
qCDebug(dcModbusCommander()) << " baud:" << baudrate;
|
qCDebug(dcModbusCommander()) << " baud:" << baudrate;
|
||||||
qCDebug(dcModbusCommander()) << " stop bits:" << stopBits;
|
qCDebug(dcModbusCommander()) << " stop bits:" << stopBits;
|
||||||
qCDebug(dcModbusCommander()) << " data bits:" << dataBits;
|
qCDebug(dcModbusCommander()) << " data bits:" << dataBits;
|
||||||
|
|
@ -263,7 +264,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
|
||||||
});
|
});
|
||||||
connect(thing, &Thing::settingChanged, thing, [thing, modbusRTUMaster] (const ParamTypeId ¶mTypeId, const QVariant &value) {
|
connect(thing, &Thing::settingChanged, thing, [thing, modbusRTUMaster] (const ParamTypeId ¶mTypeId, const QVariant &value) {
|
||||||
if (paramTypeId == modbusRTUClientSettingsNumberOfRetriesParamTypeId) {
|
if (paramTypeId == modbusRTUClientSettingsNumberOfRetriesParamTypeId) {
|
||||||
qCDebug(dcModbusCommander()) << "Set number of reties" << thing->name() << value.toUInt();
|
qCDebug(dcModbusCommander()) << "Set number of retries" << thing->name() << value.toUInt();
|
||||||
modbusRTUMaster->setNumberOfRetries(value.toUInt());
|
modbusRTUMaster->setNumberOfRetries(value.toUInt());
|
||||||
} else if (paramTypeId == modbusRTUClientSettingsTimeoutParamTypeId) {
|
} else if (paramTypeId == modbusRTUClientSettingsTimeoutParamTypeId) {
|
||||||
qCDebug(dcModbusCommander()) << "Set timeout " << thing->name() << value.toUInt();
|
qCDebug(dcModbusCommander()) << "Set timeout " << thing->name() << value.toUInt();
|
||||||
|
|
@ -276,6 +277,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
|
||||||
|| (thing->thingClassId() == discreteInputThingClassId)
|
|| (thing->thingClassId() == discreteInputThingClassId)
|
||||||
|| (thing->thingClassId() == holdingRegisterThingClassId)
|
|| (thing->thingClassId() == holdingRegisterThingClassId)
|
||||||
|| (thing->thingClassId() == inputRegisterThingClassId)) {
|
|| (thing->thingClassId() == inputRegisterThingClassId)) {
|
||||||
|
qCDebug(dcModbusCommander()) << "Setting up modbus register" << thing->name();
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
"name": "timeout",
|
"name": "timeout",
|
||||||
"displayName": "Timeout",
|
"displayName": "Timeout",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
|
"minValue": 10,
|
||||||
"defaultValue": 100
|
"defaultValue": 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -79,6 +80,7 @@
|
||||||
"name": "timeout",
|
"name": "timeout",
|
||||||
"displayName": "Timeout",
|
"displayName": "Timeout",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
|
"minValue": 10,
|
||||||
"defaultValue": 100
|
"defaultValue": 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue