Wiren Board Devices Modbus Management/en: различия между версиями

Материал из Wiren Board
(Новая страница: «<!-- {{DISPLAYTITLE:Управление устройствами Wiren Board по протоколу Modbus}} -->»)
 
(не показано 11 промежуточных версий этого же участника)
Строка 2: Строка 2:
<!-- {{DISPLAYTITLE:Управление устройствами Wiren Board по протоколу Modbus}} -->
<!-- {{DISPLAYTITLE:Управление устройствами Wiren Board по протоколу Modbus}} -->


== Параметры Modbus ==
== Modbus parameters ==


=== Modbus-адрес ===
=== Modbus address ===
Modbus-адрес устройств Wiren Board легко определить он нанесен на наклейке (адрес указан в десятичном формате). Новый адрес устройства записывается командой WRITE_SINGLE_REGISTER в регистр хранения (holding register) с адресом 128 (0x80). Подробно о том, как определить (если адрес был изменен) или изменить Modbus-адрес модуля, написано на странице [[Определение и изменение Modbus-адреса устройств Wirenboard]].
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 [[Определение и изменение Modbus-адреса устройств Wirenboard/en|Define and change the Modbus address of Wirenboard devices]].


=== Команды Modbus, поддерживаемые устройством ===
=== Modbus commands supported by the device ===


Датчики Wirenboard поддерживают все основные команды Modbus. Подробнее смотрите здесь: [[Протокол Modbus#Коды функций чтения и записи регистров|Коды функций чтения и записи регистров]].
The Wirenboard sensors support all major Modbus commands. Read more here: [[Протокол_Modbus/en#Register reading and writing function codes|Register reading and writing function codes]].


=== Modbus-регистры устройства ===
=== The Modbus-registers of the device ===
Данные и конфигурационные параметры Modbus-устройств хранятся в Modbus-регистрах. Для каждого типа устройств имеются свои карты Modbus-регистров, ссылки на которых приводятся на страницах соответствующих устройств.
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 ==


По адресу 200 хранится сигнатура модуля длиной 6 байт. Сигнатура уникальна для каждой модели устройств Wiren Board и позволяет идентифицировать модель по Modbus:
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.  
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.  
Начиная с регистра 220 записана дата сборки прошивки, в формате "число'''x00'''время'''x00'''" в виде строки (пример: 'Jan 27 2017 17:01:13'). Длина записи — 21 регистр.
Starting from register 220, the firmware build date is recorded, in the format ''number'''x00'''time'''x00''''' as a string (example: 'Jan 27 2017 17:01:13'). The length of the record is 21 registers.


== Управление устройствами из командной строки ==
== Command line device management ==
Программное обеспечение контроллера Wiren Board включает в себя утилиту modbus_client для работы с устройствами, подключенными к выходам RS-485, по протоколу Modbus, подробное описание команды находится на странице [[Modbus-client]]. Доступ к командной строке описан в статье [[SSH]].
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/en| Modbus client]]. Access to the command line is described in [[SSH/en| SSh]].


=== Пример чтения регистров ===
===Register reading example ===
Проверим, верно ли, что мы подключились именно к модулю нужного типа. (Модуль wb-mqtt-serial должен быть предварительно остановлен). По адресу 200 хранится уникальная сигнатура длиной в 6 регистров. Прочтем 6 регистров, начиная с адреса 200, и преобразуем полученный шестнадцатеричный ответ в символьную строку:
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:


<syntaxhighlight lang="bash">echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyAPP1 \
<syntaxhighlight lang="bash">echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyAPP1 \
Строка 31: Строка 31:
grep Data | sed -e 's/0x00/\\\x/g' -e 's/Data://' -e 's/\s//g'` </syntaxhighlight>
grep Data | sed -e 's/0x00/\\\x/g' -e 's/Data://' -e 's/\s//g'` </syntaxhighlight>


В результате выполнения команды получаем строку, например '''WBMS'''. Модуль WB-MS в примере имеет Modbus-адрес 1.
As a result of the command we receive string  '''WBMS'''. The WB-MS module in the example has Modbus address 1.

Текущая версия на 14:27, 3 июля 2019

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

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.