Wiren Board Devices Modbus Management

Материал из Wiren Board
Это утверждённая версия страницы. Она же — наиболее свежая версия.
Другие языки:

Modbus parameters

Modbus address

Modbus-the address of the Wiren Board devices is easy to determine — it is printed on the sticker (the address is in decimal format). The new address of the device is written by the command WRITE_SINGLE_REGISTER to the storage register (holding register) with the address 128 (0x80). For details on how to determine (if the address has been changed) or change the Modbus address of the module, see Define and change the Modbus address of Wirenboard devices.

Modbus commands supported by the device

The Wirenboard sensors support all major Modbus commands. Read more here: Register reading and writing function codes.

The Modbus-registers of the device

Data and configuration parameters of Modbus devices are stored in Modbus registers. Each type of device has its own Modbus register maps, which are referenced on the respective device pages.

Device signatures

The 6-byte module signature is stored at address 200. The signature is unique for each model of Wiren Board devices and allows to identify the model by Modbus:

To get the signature of a device you need to run command READ_HOLDING_REGISTERS at 200 (length of 6 registers). Writing to this area of memory is not supported, and error 3 is returned when attempting to write to an invalid location. Empty spaces in the signature text are clogged with the value 0x00. Starting from register 220, the firmware build date is recorded, in the format numberx00timex00 as a string (example: 'Jan 27 2017 17:01:13'). The length of the record is 21 registers.

Command line device management

The Wiren Board controller software includes modbus_client utility to work with devices connected to the RS-485 outputs, via Modbus Protocol, the detailed description of the command is on the page Modbus client. Access to the command line is described in SSh.

Register reading example

Let's check whether it is true that we are connected to the module of the desired type. (Module wb-mqtt-serial needs to be stopped). At address 200, a unique signature of 6 registers is stored. Let's read 6 registers, starting with the address 200, and convert the received hexadecimal answer into a character string:

echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyAPP1 \
-a1 -t0x03 -r200 -c 6 | \
grep Data | sed -e 's/0x00/\\\x/g' -e 's/Data://' -e 's/\s//g'`

As a result of the command we receive string WBMS. The WB-MS module in the example has Modbus address 1.