Wb-mqtt-serial driver/en: различия между версиями

Материал из Wiren Board
м (FuzzyBot переименовал страницу Драйвер wb-mqtt-serial/en в Wb-mqtt-serial driver/en без оставления перенаправления: Часть переводимой страницы Драйвер wb-mqtt-serial.)
(Новая страница: «== The configuration file of the driver ==»)
(не показано 7 промежуточных версий 2 участников)
Строка 35: Строка 35:
== The configuration file of the driver ==
== The configuration file of the driver ==


To run the driver, edit the  <code>/etc/wb-mqtt-serial.conf</code> file. An ordinary user can use the RS-485 method:[[RS-485:Настройка через веб-интерфейс|RS-485:configuration via the web interface]], which also leads to the correct filling of the configuration file. However, you can edit the file manually. To do this:
Для работы драйвера нужно отредактировать файл <code>/etc/wb-mqtt-serial.conf</code>. Обычный пользователь может воспользоваться способом [[RS-485:Настройка через веб-интерфейс|RS-485:Настройка через веб-интерфейс]], который тоже приводит к правильному заполнению файла конфигурации. Однако отредактировать файл можно и вручную, для этого:
#Read the instructions[[Special:MyLanguage/Просмотр файлов контроллера с компьютера/en|How to view controller files from your computer]]
#Ознакомьтесь с инструкцией [[Special:MyLanguage/Просмотр файлов контроллера с компьютера|Просмотр файлов контроллера с компьютера]]
#File <code>/etc/wb-mqtt-serial.conf</code> has the structure ''ports -> devices'': there are descriptions of the physical ports of the controller in the file, and inside them there is a list of devices that are connected to this port.
#Файл <code>/etc/wb-mqtt-serial.conf</code> имеет структуру ''порты (ports) -> устройства (devices)'': в файле есть описания физических портов контроллера, а внутри них - список устройств, которые подключены к этому порту.
#:Settings (speed, parity, etc.) and protocol (Modbus, RTU, etc.) are specified for each port.
#:Для каждого порта указываются настройки (скорость, чётность и т.п.), а также протокол (Modbus, RTU, etc.)
#:Each device must have its unique address on the bus - slave_id. You can also specify other optional parameters - see the [https://github.com/contactless/wb-homa-drivers/tree/master/wb-mqtt-serial full description of the format in the driver description on our Github].
#:Для каждого устройства обязательно указывается его уникальный адрес на шине - ''slave_id''. Также можно указать другие необязательные параметры - смотрите полное описание формата [https://github.com/contactless/wb-homa-drivers/tree/master/wb-mqtt-serial в описании драйвера на нашем Github].
#Enter the configuration for the ports and connected devices in the file using the examples below.
#Впишите конфигурацию для портов и подключённых устройств в файл, используя примеры ниже.
#Restart the device OR run the command from the console
#Перезагрузите устройство ИЛИ выполните из консоли команду
#: <syntaxhighlight lang="bash">
#: <syntaxhighlight lang="bash">
service wb-mqtt-serial restart
service wb-mqtt-serial restart
</syntaxhighlight>
</syntaxhighlight>
#:It will restart the driver and the connected device will appear in the web interface.
#:Она перезапустит драйвер, и подключённое устройство появится в веб-интерфейсе.
#If the device does not appear, run the following command<syntaxhighlight lang="bash">tail /var/log/messages</syntaxhighlight> or open file <code>/var/log/messages</code> and scroll to the end. If there is a line like this one:
#Если устройство не появилось, выполните команду <syntaxhighlight lang="bash">tail /var/log/messages</syntaxhighlight> или откройте файл <code>/var/log/messages</code> и промотайте его до конца. Если там будет строчка такого типа:
#:<code>May  6 17:50:58 wirenboard user.notice modbus: FATAL: Error parsing config file: Failed to parse JSON: * Line <b>15</b>, Column 17</code>
#:<code>May  6 17:50:58 wirenboard user.notice modbus: FATAL: Error parsing config file: Failed to parse JSON: * Line <b>15</b>, Column 17</code>
#:- look for the error in the 15th line of the configuration file.
#:- ищите ошибку в 15-й строке конфигурационного файла.




=== The example of configuration for relay module [[WB-MRM2 Реле 2х канальное | WB-MRM2]] connected to the isolated Wiren Board 4 port (RS-485-ISO)===
===Пример конфигурации для [[Special:MyLanguage/WB-MRM2 Реле 2х канальное | модуля реле WB-MRM2]], подключённого к изолированному порту (RS-485-ISO) Wiren Board 4===


<syntaxhighlight lang="javascript">{
<syntaxhighlight lang="javascript">{
     "ports": [
     "ports": [
         {
         {
             "path" : "/dev/ttyNSC0",  //pseudofile corresponding to port
             "path" : "/dev/ttyNSC0",  //псевдофайл, соответствующий порту
             "baud_rate": 9600, //the port speed is 9600 for almost all devices, but check the documentation first
             "baud_rate": 9600, //скорость порта, 9600 почти для всех устройств, но проверьте документацию к ним
             "parity": "N", //parity
             "parity": "N", //четность
             "data_bits": 8, //the number of data bits in the parcel
             "data_bits": 8, //битов данных в посылке
             "stop_bits": 2, //number of stop bits. Parity, bits, and stop bits are also rarely changed
             "stop_bits": 2, //количество стоп-битов. Чётность, количество битов и стоп-битов тоже редко меняются
             "poll_interval": 10, //device polling interval on the port in milliseconds
             "poll_interval": 10, //интервал опроса устройств на порту в миллисекундах
             "devices" : [
             "devices" : [
                 {
                 {
                     "device_type" : "WB-MRM2", ////device type recognized by driver
                     "device_type" : "WB-MRM2", //тип устройства, распознаваемый драйвером
                     "slave_id": 25 //device address
                     "slave_id": 25 //адрес устройства
                 }
                 }
             ]
             ]
Строка 71: Строка 71:
     ]
     ]
}</syntaxhighlight>
}</syntaxhighlight>
Узнать файл, соответствующий порту для вашего контроллера - [[Special:MyLanguage/RS-485#Реализация портов в разных версиях Wiren Board |RS-485#Реализация портов в разных версиях Wiren Board ]].


For a complete list of supported device types, see[[Поддерживаемые устройства/en|Supported devices]], and also [https://github.com/contactless/wb-homa-drivers/blob/master/wb-homa-modbus/README.md#%D0%A2%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D0%B0-%D1%88%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD%D0%BE%D0%B2-device_type here].
Полный список поддерживаемых типов устройств см. в статье [[Special:MyLanguage/Поддерживаемые устройства|Поддерживаемые устройства]], а также [https://github.com/contactless/wb-homa-drivers/blob/master/wb-homa-modbus/README.md#%D0%A2%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D0%B0-%D1%88%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD%D0%BE%D0%B2-device_type здесь].




=== An example of a configuration file for multiple connected devices ===
=== Пример конфигурационного файла для нескольких подключённых устройств ===


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">

Версия 13:17, 29 мая 2019

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

Attention! Driver wb-mqtt-serial was formerly named wb-homa-modbus, configuration file /etc/wb-mqtt-serial.conf was previously named /etc/wb-homa-modbus.conf. Keep this in mind if you are using outdated firmware.


The wb-mqtt-serial driver is responsible for working with devices connected to the Wiren Board controller via RS-485 . It provides work with connected devices through the MQTT message system. This article provides a simplified description of the driver, see the full description of the driver on our Github.


Supported Devices

Currently, work with Modbus interface devices of our production, Mercury and Milur counters, as well as with some other devices, including those operating under the Modbus Protocol, is supported. Full list of tested devices: Supported devices#RS-485 connected. Supported devices#connected via RS-485 .

Support for multiple protocol devices on the same bus

It is possible to use devices with different protocols on the same bus, but it is necessary to take into account the features of specific protocols.

For example, Uniel device frames start with byte 0xff, IVTM devices start with byte 0x24 ('$'), and in the case of Modbus, Mercury 230, and Milur protocols, the first byte of the frame is the slave ID, so when you combine such devices, you should carefully choose the slave id of Milur devices, for example, the default slave ID is 0xff, which leads to a conflict with Uniel devices. Milur Devices require additional polling delays (defined in the template) and may reduce polling speed when used on the same bus with other devices. Some devices that support additional protocols may not be compatible with other protocols on the same bus, for example, it has been observed that devices supporting the A-BUS protocol produced by "razumdom.ru" can not work on the same bus with Uniel devices. The work of the IVTM devices on the same bus with devices operating on other protocols has not been tested. Proven working combination is: Modbus + Milur (slave_id != 0xff) + Uniel on one bus.


Driver revision to support new devices

As a starting point, see the article WB-homa-modbus Driver:Examples of writing templates, for further support, contact us.


Configuring and running the driver

The driver configuration is specified in the /etc/wb-mqtt-serial.conf file. If such a file is created, the driver starts automatically when the controller is loaded. You can also control the driver manually from the console:

service wb-mqtt-serial stop #stop the driver
service wb-mqtt-serial start #start the driver
service wb-mqtt-serial restart #restart the driver
wb-mqtt-serial -c /etc/wb-mqtt-serial.conf -d #start the driver in forced debug mode with specifying the path to the configuration file


The configuration file of the driver

Для работы драйвера нужно отредактировать файл /etc/wb-mqtt-serial.conf. Обычный пользователь может воспользоваться способом RS-485:Настройка через веб-интерфейс, который тоже приводит к правильному заполнению файла конфигурации. Однако отредактировать файл можно и вручную, для этого:

  1. Ознакомьтесь с инструкцией Просмотр файлов контроллера с компьютера
  2. Файл /etc/wb-mqtt-serial.conf имеет структуру порты (ports) -> устройства (devices): в файле есть описания физических портов контроллера, а внутри них - список устройств, которые подключены к этому порту.
    Для каждого порта указываются настройки (скорость, чётность и т.п.), а также протокол (Modbus, RTU, etc.)
    Для каждого устройства обязательно указывается его уникальный адрес на шине - slave_id. Также можно указать другие необязательные параметры - смотрите полное описание формата в описании драйвера на нашем Github.
  3. Впишите конфигурацию для портов и подключённых устройств в файл, используя примеры ниже.
  4. Перезагрузите устройство ИЛИ выполните из консоли команду
    service wb-mqtt-serial restart
    
    Она перезапустит драйвер, и подключённое устройство появится в веб-интерфейсе.
  5. Если устройство не появилось, выполните команду
    tail /var/log/messages
    
    или откройте файл /var/log/messages и промотайте его до конца. Если там будет строчка такого типа:
    May 6 17:50:58 wirenboard user.notice modbus: FATAL: Error parsing config file: Failed to parse JSON: * Line 15, Column 17
    - ищите ошибку в 15-й строке конфигурационного файла.


Пример конфигурации для модуля реле WB-MRM2, подключённого к изолированному порту (RS-485-ISO) Wiren Board 4

{
     "ports": [
        {
            "path" : "/dev/ttyNSC0",  //псевдофайл, соответствующий порту
            "baud_rate": 9600, //скорость порта, 9600 почти для всех устройств, но проверьте документацию к ним
            "parity": "N", //четность
            "data_bits": 8, //битов данных в посылке
            "stop_bits": 2, //количество стоп-битов. Чётность, количество битов и стоп-битов тоже редко меняются
            "poll_interval": 10, //интервал опроса устройств на порту в миллисекундах
            "devices" : [
                {
                    "device_type" : "WB-MRM2", //тип устройства, распознаваемый драйвером
                    "slave_id": 25 //адрес устройства
                }
            ]
        }
    ]
}

Узнать файл, соответствующий порту для вашего контроллера - RS-485#Реализация портов в разных версиях Wiren Board .

Полный список поддерживаемых типов устройств см. в статье Поддерживаемые устройства, а также здесь.


Пример конфигурационного файла для нескольких подключённых устройств

// Configuration options
{
    "debug": false,
    "ports": [
        {
            "path" : "/dev/ttyNSC1",
            "baud_rate": 9600,
            "parity": "N",
            "data_bits": 8,
            "stop_bits": 2,
            "poll_interval": 0,
            "enabled": true,
            "devices" : [
                {
                    "name": "DRB88",
                    "id": "drb88",
                    "enabled": true,
                    "slave_id": "0x23",
		    "device_type" : "DRB88"
                },
                {
                    "slave_id": "0x26",
		    "device_type" : "MSU24"
                },
                {
                    "slave_id": "0x31",
		    "device_type" : "MSU34"
                },
                {
                    "slave_id": "0x04",
		    "device_type" : "LC-103"
                },
		{
		    "device_type" : "DDL24",
		    "slave_id" : "0x20"
		},	
                {
                   "enabled": true,
                  "slave_id": "0x06",
		    "device_type" : "WB-MRM2" 
               },
	       {
                 "slave_id" : 16,
		 "device_type" : "WB-MRGB"
	       }
            ]
        },
	{
	    "path" : "/dev/ttyNSC0",
	    "type": "uniel",
	    "poll_interval": 10,
	    "enabled": true,
	    "devices" : [
		{
		    "device_type" : "UCH-M141RC",
		    "slave_id": 1
		}
	    ]
	}
    ]
}