emqx / neuron

Open source industrial IoT connectivity server
https://neugates.io
GNU Lesser General Public License v3.0
1.01k stars 219 forks source link

Modbus TCP always requests address 0 #2127

Closed dakhnod closed 2 months ago

dakhnod commented 3 months ago

I have the following configuration for a Modbus TCP tag: image

And this is the log produced:

2024-07-01 21:13:23:747 [NOTICE] [Modbus sim] modbus_tcp.c:252 validate tag success, name: uint16, address: 2!30001, type: 4, slave id: 2, start address: 0, n register: 1, area: input register
2024-07-01 21:13:23:747 [NOTICE] [Modbus sim] modbus_tcp.c:252 validate tag success, name: uint16, address: 2!30001, type: 4, slave id: 2, start address: 0, n register: 1, area: input register
2024-07-01 21:13:23:747 [NOTICE] [neuron] http.c:55 <0x786e7c001cf0> PUT /api/v2/tags [200]
2024-07-01 21:13:23:783 [NOTICE] [neuron] http.c:55 <0x786e7c001cf0> GET /api/v2/tags?node=Modbus+sim&group=registers&name= [200]
2024-07-01 21:13:24:060 [NOTICE] [neuron] driver.c:1639 group: registers changed, timestamp: 1719839603747286
2024-07-01 21:13:24:061 [ERROR] [Modbus sim] modbus_req.c:264 modbus device response error, skip, 2!0
2024-07-01 21:13:25:081 [ERROR] [Modbus sim] modbus_req.c:264 modbus device response error, skip, 2!0
2024-07-01 21:13:26:101 [ERROR] [Modbus sim] modbus_req.c:264 modbus device response error, skip, 2!0

As can be seen, the start address registers as 0 and 0 is always requested. How can I make neuron request the actual register address?

dakhnod commented 3 months ago

Okay, I got an idea. It seems like you cannot just request any type of data from any address.

Could you explain the meaning of the first character in the register address? E.g. 4 in 1!400001

hxy7yx commented 3 months ago

The first character represents the storage area.