Wiren Board Devices Modbus Management

Материал из Wiren Board
Версия от 14:13, 3 июля 2019; RomanKulibaba (обсуждение | вклад) (Новая страница: «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:»)

Другие языки:

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:

Для получения сигнатуры устройства нужно выполнить команду READ_HOLDING_REGISTERS по адресу 200 (длина 6 регистров). Запись в эту область памяти не поддерживается, при попытке записи в недопустимое место возвращается ошибка 3. Пустые места в тексте сигнатуры забиваются значением 0x00. Начиная с регистра 220 записана дата сборки прошивки, в формате "числоx00времяx00" в виде строки (пример: 'Jan 27 2017 17:01:13'). Длина записи — 21 регистр.

Управление устройствами из командной строки

Программное обеспечение контроллера Wiren Board включает в себя утилиту modbus_client для работы с устройствами, подключенными к выходам RS-485, по протоколу Modbus, подробное описание команды находится на странице Modbus-client. Доступ к командной строке описан в статье SSH.

Пример чтения регистров

Проверим, верно ли, что мы подключились именно к модулю нужного типа. (Модуль wb-mqtt-serial должен быть предварительно остановлен). По адресу 200 хранится уникальная сигнатура длиной в 6 регистров. Прочтем 6 регистров, начиная с адреса 200, и преобразуем полученный шестнадцатеричный ответ в символьную строку:

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'`

В результате выполнения команды получаем строку, например WBMS. Модуль WB-MS в примере имеет Modbus-адрес 1.