fixed typos and extended readme

master
Boernsman 2020-12-07 21:52:56 +01:00
parent b673fed516
commit 78055fbdf5
5 changed files with 50 additions and 11 deletions

View File

@ -92,7 +92,7 @@ int ModbusRTUMaster::timeout()
return m_modbusRtuSerialMaster->timeout();
}
int ModbusRTUMaster::numberOfReties()
int ModbusRTUMaster::numberOfRetries()
{
return m_modbusRtuSerialMaster->numberOfRetries();
}

View File

@ -49,7 +49,7 @@ public:
void setTimeout(int timeout);
int timeout();
int numberOfReties();
int numberOfRetries();
QUuid readCoil(uint slaveAddress, uint registerAddress, uint size = 1);
QUuid readDiscreteInput(uint slaveAddress, uint registerAddress, uint size = 1);

View File

@ -1,27 +1,62 @@
# 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
* Modbus TCP client
* Gateway
* Modbus TCP interface
* IP Address and Port of the target device are requried.
* Modbus RTU client
* Gateway
* Discovery setup
* Modbus RTU interface
* All available serial ports will be discovered.
* Baudrate, data bits, stop bits and parity are required.
* Coil
* Writes and reads a single Modbus Coil
* Modbus device- and register address are required.
* Discrete input
* Reads a single Modbus discrete input
* Modbus device- and register address are required.
* Input register
* Reads a single Modbus input register
* Modbus device- and register address are required.
* Holding register
* Writes and reads a single Modbus holding register
* Modbus device- and register address are required.
## Requirements
* 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

View File

@ -177,6 +177,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
Thing *thing = info->thing();
if (thing->thingClassId() == modbusTCPClientThingClassId) {
QHostAddress hostAddress = QHostAddress(thing->paramValue(modbusTCPClientThingIpAddressParamTypeId).toString());
uint port = thing->paramValue(modbusTCPClientThingPortParamTypeId).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()) << " port:" << port;
qCDebug(dcModbusCommander()) << " number of retries:" << numberOfRetries;
@ -211,7 +212,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
});
connect(thing, &Thing::settingChanged, thing, [thing, modbusTCPMaster] (const ParamTypeId &paramTypeId, const QVariant &value) {
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());
} else if (paramTypeId == modbusTCPClientSettingsTimeoutParamTypeId) {
qCDebug(dcModbusCommander()) << "Set timeout " << thing->name() << value.toUInt();
@ -237,7 +238,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
} else if (parityString.contains("Odd")) {
parity = QSerialPort::Parity::OddParity;
}
qCDebug(dcModbusCommander()) << "Setting up RTU client";
qCDebug(dcModbusCommander()) << "Setting up RTU client" << thing->name();
qCDebug(dcModbusCommander()) << " baud:" << baudrate;
qCDebug(dcModbusCommander()) << " stop bits:" << stopBits;
qCDebug(dcModbusCommander()) << " data bits:" << dataBits;
@ -263,7 +264,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
});
connect(thing, &Thing::settingChanged, thing, [thing, modbusRTUMaster] (const ParamTypeId &paramTypeId, const QVariant &value) {
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());
} else if (paramTypeId == modbusRTUClientSettingsTimeoutParamTypeId) {
qCDebug(dcModbusCommander()) << "Set timeout " << thing->name() << value.toUInt();
@ -276,6 +277,7 @@ void IntegrationPluginModbusCommander::setupThing(ThingSetupInfo *info)
|| (thing->thingClassId() == discreteInputThingClassId)
|| (thing->thingClassId() == holdingRegisterThingClassId)
|| (thing->thingClassId() == inputRegisterThingClassId)) {
qCDebug(dcModbusCommander()) << "Setting up modbus register" << thing->name();
info->finish(Thing::ThingErrorNoError);
} else {

View File

@ -30,6 +30,7 @@
"name": "timeout",
"displayName": "Timeout",
"type": "uint",
"minValue": 10,
"defaultValue": 100
},
{
@ -79,6 +80,7 @@
"name": "timeout",
"displayName": "Timeout",
"type": "uint",
"minValue": 10,
"defaultValue": 100
},
{