ModbusAttr: Unterschied zwischen den Versionen
Krueuw (Diskussion | Beiträge) |
|||
Zeile 187: | Zeile 187: | ||
Therefore it is typically necessary to specify the data representation as a Perl unpack code. | Therefore it is typically necessary to specify the data representation as a Perl unpack code. | ||
A Modbus master can also write values to Objects in the device and attributes define how this is done. | A Modbus master can also write values to Objects in the device and attributes define how this is done. | ||
{{Randnotiz | RNTyp=y | RNText=To set the following attributes, modify the examples and then add them to the FHEM command line at the top of the web interface. The usual procedure in the web interface is apparently only supported afterwards.}} | |||
Example for a Modbus master or passive configuration: | Example for a Modbus master or passive configuration: |
Version vom 14. April 2024, 20:01 Uhr
ModbusAttr | |
---|---|
Zweck / Funktion | |
Extract information from devices with a Modbus interface or send information to such devices | |
Allgemein | |
Typ | Gerätemodul |
Details | |
Dokumentation | EN / DE Thema |
Support (Forum) | Sonstiges |
Modulname | 98_ModbusAttr.pm |
Ersteller | StefanStrobel (Forum / Wiki) |
Wichtig: sofern vorhanden, gilt im Zweifel immer die (englische) Beschreibung in der commandref! |
ModbusAttr uses the low level Modbus module 98_Modbus.pm to provide a generic Modbus module (as master, slave, relay or passive listener)
that can be configured by attributes similar to the way HTTPMOD works for devices with a web interface.
ModbusAttr can be used as a Modbus master that queries data from other devices over a serial RS232 / RS485 or TCP connection, it can be used as a Modbus slave that can make readings of Fhem devices available via Modbus to external Modbus masters, it can act as a Modbus relay that receives requests over one connection and forwards them over another connection (e.g. from Modbus TCP to serial Modbus RTU) or it can passively listen to other devices that communicate over a serial RS485 connection and extract readings from the objects it sees. The supported protocols are Modbus RTU, Modbus ASCII or Modbus TCP.
There are several attributes that modify the way data objects are converted before they are stored in readings or sent to a device. Data can be modified by a perl expression defined in an atribute, formatted with a format string defined in another attribute or mapped to a table defined in an attribute.
Readings can directly correspond to one data object or they can span several objects. A float value for example might be stored in two input or holding registers in the Modbus device. By specifying attributes that define the length of a reading in objects and by specifying the unpack code to get from a raw string to perl variables, all these cases can be described by attributes and no perl coding is necessary.
Availability
The module has been checked in.
Prerequisites
This module uses the Modbus base module 98_Modbus.pm which uses the DevIO module
Define as Modbus master
define <iodevice> Modbus /dev/device@baudrate,bits,parity,stop define <name> ModbusAttr <Id> <Interval> <RTU|ASCII>
or
define <name> ModbusAttr <Id> <Interval> <Address:Port> <RTU|ASCII|TCP>
In the first case the module connects to the external Modbus device with Modbus Id <Id> through a serial modbus device (RS232 or RS485).
In the second case it connects directly through Modbus TCP or Modbus RTU or ASCII over TCP.
If <Interval> is not 0 then the module actively requests data from that device every <Interval> seconds.
The objects that the module should request and the readings it should create from these objects have to be defined with attributes (see below). These attributes will define a mapping from so called "coils", "digital inputs", "input registers" or "holding registers" of the external device to readings inside Fhem together with the data type and format of the values. Interval can be 0 in which case the Module only requests data when it is triggered with a Fhem get-Command. With this mode a Fhem installation can for example query sensor data from a heating system, energy meter or solar power installation if these systems offer a Modbus interface.
Examples:
define ModbusLine Modbus /dev/ttyUSB1@9600 define WP ModbusAttr 1 60
Define WP as a Modbus master that communicates through the Modbus serial interface device named ModbusLine. The protocol defaults to Modbus RTU
define ModbusLine Modbus /dev/ttyUSB1@9600 define WP ModbusAttr 20 0 ASCII
Define WP as a Modbus master that communicates through the Modbus serial interface device named ModbusLine with Modbus ASCII. Use Modbus Id 20 and don't query the device in a defined interval. Instead individual SET / GET options have to be used for communication.
define WP ModbusAttr 5 60 192.168.1.122:502 TCP
to talk Modbus TCP to a device with IP-Address 192.168.1.122 and the reserved port for Modbus TCP 502 Note that for Modbus over a TCP connection you don't need a basic Modbus device for the interface like ModbusLine above.
define WP ModbusAttr 3 60 192.168.1.122:8000 RTU
to talk Modbus RTU over TCP and use the port number 8000
Define as Modbus slave
define <name> ModbusAttr <Id> slave
or
define <name> ModbusAttr <Id> slave <Address:Port> <RTU|ASCII|TCP>
The module waits for connections from other Modbus masters. It will respond to their requests if the requests contain the given Modbus <Id> To provide data with Modbus to external Modbus masters a mapping needs to be defined using attributes. These attributes will define a mapping from Readings inside Fhem to so called "coils", "digital inputs", "input registers" or "holding registers" and their Modbus object address together with the data type and format of the values. With this mode a Fhem installation can for example supply data to a PLC that actively reads data from Fhem or writes data to Fhem readings.
Examples:
define MRS485 Modbus /dev/ttyUSB2@9600,8,E,1 define Data4PLC ModbusAttr 1 slave
Define Data4PLC as a Modbus slave that communicates through the Modbus serial interface device named MRS485 to listen for Modbus requests with Id 1. The protocol defaults to Modbus RTU
define MRS485 Modbus /dev/ttyUSB2@9600,8,E,1 define Data4PLC ModbusAttr 20 slave ASCII
to listen for Modbus requests with Id 20 with Modbus ASCII.
define Data4PLC ModbusAttr 5 slave 192.168.1.2:502 TCP
to start listening to TCP port 502 on the local address 192.168.1.2. Modbus TCP will be used as protocol and Requests with Modbus Id 5 will be answered.
Please be aware that opening a port number smaller than 1024 needs root permissions on Unix devices. So it is probably better to use a non standard port number above 1024 instead.
define Data4PLC ModbusAttr 3 slave 192.168.1.2:8000 RTU
to listen to the local port 8000 and talk Modbus RTU over TCP
Define as Modbus passive listener
define <name> ModbusAttr <Id> passive <RTU|ASCII|TCP>
The module listens on a serial (RS485) connection for modbus communication with the given Modbus <Id> and extracts readings. It does not send requests by itself but waits for another master to communicate with a slave. So only objects that the other master requests can be seen by Fhem in this configuration. The objects that the module recognizes and the readings that it should create from these objects have to be defined with attributes (see below) in the same way as for a Modbus master. These attributes will define a mapping from so called "coils", "digital inputs", "input registers" or "holding registers" of the external device to readings inside Fhem together with the data type and format of the values. With this mode a Fhem installation can for example Listen to the communication between an energy counter as slave and a solar control system as master if they use Modbus RTU over RS485. Since only one Master is allowed when using Modbus over serial lines, Fhem can not be master itself. As a passive listener it can however see when the master queries e.g. the current power consumption and then also see the reply from the energy meter and store the value in a Fhem reading.
Examples:
define MB-485 Modbus /dev/ttyUSB2 define WP ModbusAttr 1 passive
to passively listen for Modbus requests and replies with Id 1 over a serial interface managed by an already defined basic modbus device named MB-485. The protocol defaults to Modbus RTU
define MB-485 Modbus /dev/ttyUSB2 define WP ModbusAttr 20 passive ASCII
to passivel listen for Modbus requests / replies with Id 20 and Modbus ASCII.
Define as Modbus relay
define <name> ModbusAttr <Id> relay to <FhemMasterDevice>
for a relay from a serial line to a defined master or
define <name> ModbusAttr <Id> relay <Address:Port> <RTU|ASCII|TCP> to <FhemMasterDevice>
For a relay that listens to modbus requests from a network connection.
The module waits for connections from other Modbus masters. It will forward requests if they match the given Modbus <Id> to an already defined Modbus Master device inside Fhem which will send them to its defined slave, take the reply and then pass it back to the original Master. With this mode a Fhem installation can for example be used in front of a device that only speaks Modbus RTU over RS485 to make it available via Modbus TCP over the local network.
Examples:
define MB-485 Modbus /dev/ttyUSB2 define Heating ModbusAttr 22 0 define Relay ModbusAttr 33 relay 192.168.1.2:1502 TCP to Heating
Defines MB-485 as a base device for the RS-485 communication with a heating system, defines Heating as a Modbus Master to communicate with the Heating and its Modbus ID 22, and then defines the relay which listens to the local IP address 192.168.1.2, TCP port 1502, Modbus Id 33 and protocol Modbus-TCP. Requests coming in through Modbus TCP and port 1502 are then translated to Modbus RTU and forwarded via RS-485 to the heating system with Modbus Id 22.
Please note that the IP address specified in the relay definition is a local IP address of the relay itself and that the port number is 1502, not 502 because Fhem running on Linux can not easily open listening port numbers below 1024 unless it is running as root.
Other (unlikely) Example:
define MB-232 Modbus /dev/ttyUSB2@19200 define Solar ModbusAttr 7 0 192.168.1.122:502 RTU define PLC2NetRelay ModbusAttr 1 ASCII relay to Solar
Defines MB-232 as a base device for the RS-232 communication with a PLC as Modbus master, defines Solar as a Modbus Master to communicate with Modbus TCP to a Solar power system at IP Adrress 192.168.1.122 and its Modbus ID 7, and then defines the PLC2NetRelay as a relay which listens to Modbus-ASCII requests over the serial RS-232 link from a PLC to Modbus ID 1. Requests to Modbus Id 1 coming in through the serial link are then translated to Modbus TCP and forwarded over the network to the solar power system with Modbus Id 7.
Configuration of the module as master or passive listener
Data objects (holding registers, input registers, coils or discrete inputs) are defined using attributes. If Fhem is Modbus master or passive listener, the attributes assign data objects of external devices (heating systems, power meters, PLCs or other) with their register addresses to readings inside fhem and control how these readings are calculated from the raw values and how they are formatted. Please be aware that Modbus does not define common data types so the representation of a value can be very different from device to device. One device might make a temperature value avaliable as a floating point value that is stored in two holding resgisters, another device might store the temperature multiplied with 10 as an signed integer in one register. Even the order of bytes can vary. Therefore it is typically necessary to specify the data representation as a Perl unpack code. A Modbus master can also write values to Objects in the device and attributes define how this is done.
![Emblem-question-yellow.svg](/w/images/thumb/a/aa/Emblem-question-yellow.svg/20px-Emblem-question-yellow.svg.png)
Example for a Modbus master or passive configuration:
define PWP ModbusAttr 5 30 attr PWP obj-h256-reading Temp_Wasser_ein attr PWP obj-h256-expr $val/10 attr PWP obj-h258-reading Temp_Wasser_Aus attr PWP obj-h258-expr $val/10 attr PWP obj-h262-reading Temp_Luft attr PWP obj-h262-expr $val / 10 attr PWP obj-h770-reading Temp_Soll attr PWP obj-h770-expr $val / 10 attr PWP obj-h770-set 1 attr PWP obj-h770-setexpr $val * 10 attr PWP obj-h770-max 32 attr PWP obj-h770-min 10 attr PWP obj-h770-hint 8,10,20,25,28,29,30,30.5,31,31.5,32 attr PWP dev-h-combine 5 attr PWP dev-h-defPoll 1 attr PWP dev-h-defUnpack n attr PWP room Pool-WP attr PWP stateFormat {sprintf("%.1f Grad", ReadingsVal($name,"Temp_Wasser_Ein",0))} attr PWP webCmd Temp_Soll
Attributes to define data objects start with obj- followed by a code that identifies the type and address of the data object.
Modbus devices offer the following types of data objects:
- holding registers (16 bit objects that can be read and written)
- input registers (16 bit objects that can only be read)
- coils (single bit objects that can be read and written)
- discrete inputs (single bit objects that can only be read)
The module uses the first character of these data object types to define attributes. Thus h770 refers to a holding register with the decimal address 770 and c120 refers to a coil with address 120. The address has to be specified as pure decimal number. The address counting starts at address 0
Please note that the documentation for devices sometimes uses different numbering. They might start counting with one instead of zero so if a voltage value is stored in input register number 107 according to the documentation of the device, it might technically mean register number 106 (in the Modbus protocol specification addresses start with 0). Also some vendors use hexadecimal descriptions of their register addresses. So input register 107 might be noted as hex and means 263 or even 262 as decimal address.
attr PWP obj-h258-reading Temp_Wasser_Aus
defines a reading with the name Temp_Wasser_Aus that is read from the Modbus holding register at address 258.
With the attribute ending on -expr
you can define a perl expression to do some conversion or calculation on the raw value read from the device.
In the above example the raw value has to be devided by 10 to get the real value. If the raw value is also the final value then no -expr
attribute is necessary.
An object attribute ending on -set
creates a fhem set option.
In the above example the reading Temp_Soll can be changed to 12 degrees by the user with the fhem command set PWP Temp_Soll 12
The object attributes ending on -min
and -max
define min and max values for input validation
and the attribute ending on -hint
will tell fhem to create a selection list so the user can graphically select the defined values.
To define general properties of the device you can specify attributes starting with dev-
.
E.g. with dev-timing-timeout
you can specify the timeout when waiting for a response from the device.
With dev-h-
you can specify several default values or general settings for all holding registers
like the function code to be used when reading or writing holding registers.
These attributes are optional and the module will use defaults that work in most cases.
dev-h-combine 5
for example allows the module to combine read requests to objects having an address that differs 5 or less into one read request.
Without setting this attribute the module will start individual read requests for each object.
Typically the documentation for the modbus interface of a given device states the maximum number of objects that can be read in one function code 3 request.
dev-h-defUnpack n
means that the values in this example that the values are stored as unsigned short (16-bit) in "network" (big-endian) order. This is only one possibility of many. An integer value might be signed instead of unsigned or it might use different byte ordering (e.g. unpack codes v or s).
Handling Data Types
The Modbus protocol does not define data types. If the documentation of a device states that for example the current temperature is stored in holding register 102 this leaves room for many interpretations. Not only can the address 102 mean different things (actually decimal 102 or rather 101 if the vendor starts counting at 1 instead of 0 or even 257 or 258 if the vendor used hexadecimal addresses in his documentation ) also the data representation can be many different things. As in every programming language, there are many ways to represent numbers. They can be stored signed or unsigned, they can be integers or floating point numbers, the byte-order can be "big endian" or "small endian", the value can be stored in one holding register or in two holding registers (floating point numbers typically take four bytes which means two holding registers). The Modbus module allows flexible configuration of data representations be assigning a Perl unpack-code, a length, a Perl Expression, and the register ordering. The following example illustrates how this can be done:
attr PWP obj-h338-reading Pressure attr PWP obj-h338-len 2 attr PWP obj-h338-unpack f> attr PWP obj-h338-revRegs 1 attr PWP obj-h338-format %.2f
In This example a floating point value for the reading "Pressure" is read from the holding registers starting at address 338. The value occupies 32 Bits and is therefore stored in two registers. The Perl pack code to use is f> which means a native single precision float in big endian format (byte order). With revRegs the module is instructed to reverse the order of the registers directly after reading. The format specification then defines how the value is formatted into a reading - in this case with two digits after the comma. See http://perldoc.perl.org/functions/pack.html for Perl pack / unpack codes and http://perldoc.perl.org/functions/sprintf.html for format specifications.
If you need to read / write many objects for a device, defining all these parameters each time is not elegant. The Modbus module therefore offers twi ways to simplify this task: You can define defaults for every type of object or you can define your own data types once and then refer to them. This exampe shows how defaults can be specified for holding registers and input registers:
attr PWP dev-h-defUnpack f> attr PWP dev-h-defLen 2 attr PWP dev-h-defRevRegs 1 attr PWP dev-h-defFormat %.2f attr PWP dev-i-defUnpack n attr PWP dev-i-defLen 1
The next example shows how you can define your own data types and then apply them to objects:
attr WP dev-type-VT_R4-format %.1f attr WP dev-type-VT_R4-len 2 attr WP dev-type-VT_R4-revRegs 1 attr WP dev-type-VT_R4-unpack f> attr WP obj-h1234-reading Temp_In attr WP obj-h1234-type VT_R4 attr WP obj-h1236-reading Temp_Out attr WP obj-h1236-type VT_R4
This example defines a data type with the name VT_R4 which uses an unpack code of f>, length 2 and reversed register ordering. It then assigns this Type to the objects Temp_In and Temp_Out.
Configuration of the module as Modbus slave
Data objects that the module offers to external Modbus masters (holding registers, input registers, coils or discrete inputs) are defined using attributes. If Fhem is Modbus slave, the attributes assign readings of Fhem devices to Modbus objects with their addresses and control how these objects are calculated from the reading values that exist in Fhem. It is also possible to allow an external Modbus master to send write function codes and change the value of readings inside Fhem.
Example for a Modbus slave configuration:
define MRS485 Modbus /dev/ttyUSB2@9600,8,E,1 define Data4PLC ModbusAttr 1 slave attr Data4PLC IODev MRS485 attr Data4PLC obj-h256-reading THSensTerrasse:temperature attr Data4PLC obj-h256-unpack f attr Data4PLC obj-h256-len 2 attr Data4PLC obj-h258-reading THSensTerrasse:humidity attr Data4PLC obj-h258-unpack f attr Data4PLC obj-h258-len 2 attr Data4PLC obj-h260-reading myDummy:limit attr Data4PLC obj-h260-unpack n attr Data4PLC obj-h260-len 1 attr Data4PLC obj-h260-allowWrite 1
In this example Fhem allows an external Modbus master to read the temperature of a Fhem device named THSensTerrasse through holding register 256 and the humidity of that Fhem device through holding register 258. Both are encoded as floting point values that span two registers. The master can also read but also write the reading named limit of the device myDummy.
Set-Commands
can be defined for holding registers and coils by using attributes.
Every object for which an attribute like obj-xy-set
is set to 1 will create a valid set option.
Additionally the attribute enableControlSet
enables the set options interval
, stop
, start
, reread
as well as scanModbusObjects
, scanStop
and scanModbusIds
(for devices connected with RTU / ASCII over a serial line).
interval <Interval>
- modifies the interval that was set during define.
stop
- stops the interval timer that is used to automatically poll objects through Modbus.
start
- starts the interval timer that is used to automatically poll objects through Modbus.
- If an interval is specified during the define command then the interval timer is started automatically.
- However if you stop it with the command
set <mydevice> stop
- then you can start it again with
set <mydevice> start
.
reread
- causes a read of all objects that are set to be polled in the defined interval. The interval timer is not modified.
scanModbusObjects <startObj> - <endObj> <reqLen>
- scans the device objects and automatically creates attributes for each reply it gets.
- This might be useful for exploring devices without proper documentation.
- The following example starts a scan and queries the holding registers with addresses between 100 and 120.
set MyModbusAttrDevice scanModbusObjects h100-120
- For each reply it gets, the module creates a reading like
scan-h100 hex=0021, string=.!, s=8448, s>=33, S=8448, S>=33
- the representation of the result as hex is 0021 and
- the ASCII representation is .!. s, s>, S and S> are different representations with their Perl pack-code.
scanModbusIds <startId> - <endId> <knownObj>
- scans for Modbus Ids on an RS485 Bus. The following set command for example starts a scan:
set Device scanModbusId 1-7 h770
- since many Modbus devices don't reply at all if an object is requested that does not exist,
- scanModbusId needs the adress of an object that is known to exist.
- If a device with Id 5 replies to a read request for holding register 770, a reading like the following will be created:
scanId-5-Response-h770 hex=0064, string=.d, s=25600, s>=100, S=25600, S>=100
scanStop
- stops any running scans.
- saveAsModule <name>
- experimental: saves the definitions of obj- and dev- attributes in a new fhem module file as /tmp/98_ModbusGen<name>.pm.
- if this file is copied into the fhem module subdirectory (e.g. /opt/fhem/FHEM) and fhem is restarted then instead of defining a device
- as ModbusAttr with all the attributes to define objects, you can just define a device of the new type ModbusGen<name> and all the
- objects will be there by default. However all definitions can still be changed / overriden with the attribues defined in ModbusAttr if needed.
Get-Commands
Every reading can be manually requested by a Get.
Internally a Get command triggers the corresponding Modbus request to the device and the module then interprets the data and sets the right Fhem readings. To avoid huge option lists in FHEMWEB, the objects visible as Get in FHEMWEB can be defined by setting an attribute obj-xy-showGet
to 1.
All Attributes
- readingFnAttributes
- the usual Fhem attributes for all devices
- alignTime
- Aligns each periodic read request for the defined interval to this base time.
- This is typcally something like 00:00 (see the Fhem at command)
- enableControlSet
- enables the built in set commands like interval, stop, start and reread (see above)
the following list of attributes can be applied to any data object by specifying the objects type and address in the variable part. For many attributes you can also specify default values per object type (see dev- attributes later) or you can specify an object attribute without type and address (e.g. obj-len) which then applies as default for all objects:
- obj-[cdih][1-9][0-9]*-reading
- define the name of a reading that corresponds to the Modbus data object of type c,d,i or h and a decimal address (e.g. obj-h225-reading).
- obj-[cdih][1-9][0-9]*-name
- defines an optional internal name of this data object (this has no meaning for fhem and serves mainly documentation purposes.
- obj-[cdih][1-9][0-9]*-set
- if set to 1 then this data object can be changed (works only for holding registers and coils since discrete inputs and input registers can not be modified by definition.
- obj-[cdih][1-9][0-9]*-min
- defines a lower limit to the value that can be written to this data object. This ist just used for input validation.
- obj-[cdih][1-9][0-9]*-max
- defines an upper limit to the value that can be written to this data object. This ist just used for input validation.
- obj-[cdih][1-9][0-9]*-hint
- this is used for set options and tells fhemweb what selection to display for the set option (list or slider etc.)
- obj-[cdih][1-9][0-9]*-expr
- defines a perl expression that converts the raw value read from the device.
- obj-[cdih][1-9][0-9]*-ignoreExpr
- defines a perl expression that returns 1 if a value should be ignored and the existing reading should not be modified
- obj-[cdih][1-9][0-9]*-map
- defines a map to convert values read from the device to more convenient values when the raw value is read from the device or back when the value to write has to be converted from the user value to a raw value that can be written. Example: 0:mittig, 1:oberhalb, 2:unterhalb
- obj-[cdih][1-9][0-9]*-setexpr
- defines a perl expression that converts the user specified value in a set to a raw value that can be sent to the device. This is typically the inversion of -expr above.
- obj-[cdih][1-9][0-9]*-format
- defines a format string to format the value read e.g. %.1f
- obj-[cdih][1-9][0-9]*-len
- defines the length of the data object in registers. It defaults to 1. Some devices store 32 bit floating point values in two registers. In this case you can set this attribute to two.
- obj-[cdih][1-9][0-9]*-unpack
- defines the unpack code to convert the raw data string read from the device to a reading. For an unsigned integer in big endian format this would be "n", for a signed 16 bit integer in big endian format this would be "s>" and for a 32 bit big endian float value this would be "f>". (see the perl documentation of the pack function).
- obj-[cdih][1-9][0-9]*-revRegs
- this is only applicable to objects that span several input registers or holding registers.
- when they are read then the order of the registers will be reversed before
- further interpretation / unpacking of the raw register string.
- The same happens before the object is written with a set command.
- obj-[cdih][1-9][0-9]*-bswapRegs
- this is applicable to objects that span several input or holding registers.
- After the registers have been read and before they are writtem,
- all 16-bit values are treated big-endian and are reversed to little-endian by swapping the two 8 bit bytes.
- This functionality is most likely used for reading (ASCII) strings from the device
- that are stored as big-endian 16-bit values.
- example: original reading is "324d3130203a57577361657320722020". After applying bswapRegs,
- the value will be "4d3230313a2057576173736572202020" which will result in the ASCII string
- "M201: WWasser ".
- Should be used with "(a*)" as -unpack value.
- obj-[cdih][1-9][0-9]*-decode
- defines an encoding to be used in a call to the perl function decode to convert the raw data string
- read from the device to a reading.
- This can be used if the device delivers strings in an encoding like cp850 instead of utf8.
- obj-[cdih][1-9][0-9]*-encode
- defines an encoding to be used in a call to the perl function encode to convert the raw data string
- read from the device to a reading.
- This can be used if the device delivers strings in an encoding like cp850 and after decoding it you want to reencode it to e.g. utf8.
- obj-[cdih][1-9][0-9]*-showGet
- every reading can also be requested by a get command. However these get commands are not automatically offered in fhemweb. By specifying this attribute, the get will be visible in fhemweb.
- obj-[cdih][1-9][0-9]*-poll
- if set to 1 then this obeject is included in the cyclic update request as specified in the define command. If not set, then the object can manually be requested with a get command, but it is not automatically updated each interval. Note that this setting can also be specified as default for all objects with the dev- atributes described later.
- obj-[cdih][1-9][0-9]*-polldelay
- this attribute allows to poll objects at a lower rate than the interval specified in the define command. you can either specify a time in seconds or number prefixed by "x" which means a multiple of the interval of the define command. if you specify a normal numer then it is interpreted as minimal time between the last read and another automatic read. Please note that this does not create an individual interval timer. Instead the normal interval timer defined by the interval of the define command will check if this reading is due or not yet. So the effective interval will always be a multiple of the interval of the define.
- dev-([cdih]-)*read
- specifies the function code to use for reading this type of object. The default is 3 for holding registers, 1 for coils, 2 for discrete inputs and 4 for input registers.
- dev-([cdih]-)*write
- specifies the function code to use for writing this type of object. The default is 6 for holding registers and 5 for coils. Discrete inputs and input registers can not be written by definition.
- dev-([cdih]-)*combine
- defines how many adjacent objects can be read in one request. If not specified, the default is 1
- dev-([cdih]-)*defLen
- defines the default length for this object type. If not specified, the default is 1
- dev-([cdih]-)*defFormat
- defines a default format string to use for this object type in a sprintf function on the values read from the device.
- dev-([cdih]-)*defExpr
- defines a default Perl expression to use for this object type to convert raw values read.
- dev-([cdih]-)*defIgnoreExpr
- defines a default Perl expression to decide when values should be ignored.
- dev-([cdih]-)*defUnpack
- defines the default unpack code for this object type.
- dev-([cdih]-)*defRevRegs
- defines that the order of registers for objects that span several registers will be reversed before
- further interpretation / unpacking of the raw register string
- dev-([cdih]-)*defBswapRegs
- per device default for swapping the bytes in Registers (see obj-bswapRegs above)
- dev-([cdih]-)*defDecode
- defines a default for decoding the strings read from a different character set e.g. cp850
- dev-([cdih]-)*defEncode
- defines a default for encoding the strings read (or after decoding from a different character set) e.g. utf8
- dev-([cdih]-)*defPoll
- if set to 1 then all objects of this type will be included in the cyclic update by default.
- dev-([cdih]-)*defShowGet
- if set to 1 then all objects of this type will have a visible get by default.
- dev-timing-timeout
- timeout for the device (defaults to 2 seconds)
- dev-timing-sendDelay
- delay to enforce between sending two requests to the device. Default ist 0.1 seconds.
- dev-timing-commDelay
- delay between the last read and a next request. Default ist 0.1 seconds.
- dev-([cdih]-)*allowShortResponses
- if set to 1 the module will accept a response with valid checksum but data lengh < lengh in header
- dev-timing-timeout
- timeout for the device (defaults to 2 seconds)
- dev-timing-sendDelay
- delay to enforce between sending two requests to the device. Default ist 0.1 seconds.
- dev-timing-commDelay
- delay between the last read and a next request. Default ist 0.1 seconds.
- nextOpenDelay
- delay for Modbus-TCP connections.
- This defines how long the module should wait after a failed TCP connection attempt before the next reconnection attempt.
- This defaults to 60 seconds.
- openTimeout
- timeout to be used when opening a Modbus TCP connection (defaults to 3)
- timeoutLogLevel
- log level that is used when logging a timeout. Defaults to 3.
- silentReconnect
- if set to 1, then it will set the loglevel for "disconnected" and "reappeared" messages to 4 instead of 3
- maxTimeoutsToReconnect
- this attribute is only valid for TCP connected devices.
- In such cases a disconnected device might stay undetected and lead to timeouts until the TCP connection is reopened.
- This attribute specifies after how many timeouts an automatic reconnect is tried.
- dev-h-brokenFC3
- workaround for some broken Modbus function code 3 implementations
- disable
- stop communication with the device while this attribute is set to 1. For Modbus over TCP this also closes the TCP connection.
Links
- Modbus.org
- About Modbus (English / German)
- Perl unpack codes