Подобрал задержку, при которой ошибки не возникают, но топики поменялись местами.
Шаблон:
{
"device_type": "PH-CL",
"device":
{
"name": "PH-CL",
"id": "ph-cl",
"max_read_registers": 1,
"guard_interval_us": 5000000,
"channels":
[
{
"address": 3,
"name": "Current Cl",
"original_name": "Текущее значение Хлора значение умноженное на 100",
"type": "value",
"reg_type": "holding_multi",
"scale": 0.01,
"readonly": true
},
{
"address": 4,
"name": "Current Ph",
"original_name": "Текущее значение Ph умноженное на 100",
"type": "value",
"reg_type": "holding_multi",
"scale": 0.01,
"readonly": true
}
]
}
}
Чтение через modbus_client:
root@IQ306002:~# modbus_client --debug -mrtu -pnone -s1 /dev/ttyRS485-2 -t3 -r3 -c 2
Opening /dev/ttyRS485-2 at 9600 bauds (N, 8, 1)
[01][03][00][03][00][02][34][0B]
Waiting for a confirmation...
<01><03><04><00><16><00><47><5B><C5>
SUCCESS: read 2 of elements:
Data: 0x0016 0x0047
Чтение через wb-mqtt-serial:
root@IQ306002:~# mosquitto_sub -t /devices/# -v | grep ph-cl
/devices/ph-cl_1/meta {"driver":"wb-modbus","title":{"en":"PH-CL 1"}}
/devices/ph-cl_1/meta/driver wb-modbus
/devices/ph-cl_1/meta/name PH-CL 1
/devices/ph-cl_1/controls/Current Cl 0.71
/devices/ph-cl_1/controls/Current Cl/meta {"order":1,"readonly":true,"type":"value"}
/devices/ph-cl_1/controls/Current Cl/meta/order 1
/devices/ph-cl_1/controls/Current Cl/meta/readonly 1
/devices/ph-cl_1/controls/Current Cl/meta/type value
/devices/ph-cl_1/controls/Current Ph 0.23
/devices/ph-cl_1/controls/Current Ph/meta {"order":2,"readonly":true,"type":"value"}
/devices/ph-cl_1/controls/Current Ph/meta/order 2
/devices/ph-cl_1/controls/Current Ph/meta/readonly 1
/devices/ph-cl_1/controls/Current Ph/meta/type value
/devices/ph-cl_1/controls/Current Ph 0.2
С чем это может быть связано? Как исправить?
Причем, если перезапустить wb-mqtt-serial, показания снова могут поменяться местами.
root@IQ306002:~# service wb-mqtt-serial restart
root@IQ306002:~# mosquitto_sub -t /devices/ph-cl_1/controls/# -v
/devices/ph-cl_1/controls/Current Cl/meta {"order":1,"readonly":true,"type":"value"}
/devices/ph-cl_1/controls/Current Cl/meta/error (null)
/devices/ph-cl_1/controls/Current Cl/meta/order 1
/devices/ph-cl_1/controls/Current Cl/meta/readonly 1
/devices/ph-cl_1/controls/Current Cl/meta/type value
/devices/ph-cl_1/controls/Current Cl 0.72
/devices/ph-cl_1/controls/Current Ph/meta {"order":2,"readonly":true,"type":"value"}
/devices/ph-cl_1/controls/Current Ph/meta/error (null)
/devices/ph-cl_1/controls/Current Ph/meta/order 2
/devices/ph-cl_1/controls/Current Ph/meta/readonly 1
/devices/ph-cl_1/controls/Current Ph/meta/type value
/devices/ph-cl_1/controls/Current Ph 0.19
/devices/ph-cl_1/controls/Current Cl 0.2 # вот тут путаница
/devices/ph-cl_1/controls/Current Ph 0.72
/devices/ph-cl_1/controls/Current Cl 0.19
/devices/ph-cl_1/controls/Current Cl 0.2
/devices/ph-cl_1/controls/Current Cl 0.19
/devices/ph-cl_1/controls/Current Cl 0.2
/devices/ph-cl_1/controls/Current Cl/meta/error r
/devices/ph-cl_1/controls/Current Ph 0.19
/devices/ph-cl_1/controls/Current Cl 0.72 # и здесь снова
/devices/ph-cl_1/controls/Current Cl/meta/error (null)
Версия wb-mqtt-serial 2.68.6