simonvetter / modbus

Go modbus stack (client and server)
MIT License
262 stars 83 forks source link

'protocol error' on CentOS7 Ubantu20.04 #27

Open wgchaoer opened 1 year ago

wgchaoer commented 1 year ago

modbus-cli image

The target device can normally read the value of each register by the modbus poll software of the Windows system. But only the part of the coil can be read through this modbus-cli program。

This problem also occurs in modbus_exporter and telegraf modbus input plugin modules, the error contents are as follows:

response data size '1' does not match count '2'

I have tried various types of combination configurations, but still cannot achieve normal data collection。

Reference link: modbus_exporter: https://github.com/RichiH/modbus_exporter telegraf.inputs: https://github.com/influxdata/telegraf/blob/release-1.24/plugins/inputs/modbus/README.md

The above error messages will not generally appear on the equipment, but on individual equipment, such as circuit breakers in electrical equipment. The registers simulated by the simulator are normal after testing.

wgchaoer commented 1 year ago

This article mentioned the following data types about INT8 register datatype: INT8L, INT8H, UINT8L, UINT8H https://github.com/influxdata/telegraf/blob/release-1.25/plugins/inputs/modbus/README.md#register-datatype

and I found a similar mistake. Maybe I can find some answers from it https://github.com/grid-x/modbus/issues/52

simonvetter commented 1 year ago

Hi wgchaoer,

what brand and model of breaker are you seeing this with? I see you're reading input registers. If you try reading holding registers, does that help in any way? You can read holding registers with rh::

instead of ri::
.

My hunch is that the target device doesn't properly implement the modbus/tcp protocol and returns short or non-compliant data instead. This is something I've seen multiple times with RTU devices, for sure.