LogicMachine Forum
Possible bug in modbus reading - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Possible bug in modbus reading (/showthread.php?tid=6554)



Possible bug in modbus reading - Ceros2112 - 17.09.2026

Hello,

I have to read (unfortunately) some modbus registers starting from 40000, at first I thought that they are Holding registers starting from N°0 but no...they start literally from 40000...

And thats the possible bug: if I set, for example, holding register 40056 in the JSON profile it doesn't read anything, but if I read it with luamodbus it works...I suspect that the modbus implementation take the 4 in 40056 as the function and so it reads the holding register 56...

is there a way to avoid making a custom script and use the built in modbus function?

thank you


RE: Possible bug in modbus reading - admin - 17.09.2026

The address from the profile is used as is. Post your profile.


RE: Possible bug in modbus reading - Ceros2112 - 17.09.2026

See the last register, the others are wrong, the same thing happens if I read it via a manual reading test


Code:
{     "manufacturer": "Viessmann",     "description": "Termostato PCUSM - Modbus RTU",     "read_swap": "n",     "mapping": [         {             "bus_datatype": "float16",             "datatype": "uint16",             "address": 0,             "units": "V",             "writable": true,             "type": "register",             "name": "Recuperatore 1 - Ventilazione - Velocità minima ventilatore mandata"         },         {             "bus_datatype": "float16",             "datatype": "uint16",             "address": 1,             "units": "V",             "writable": true,             "type": "register",             "name": "Recuperatore 1 - Ventilazione - Velocità massima ventilatore mandata"         },         {             "bus_datatype": "float16",             "datatype": "uint16",             "address": 2,             "units": "V",             "writable": true,             "type": "register",             "name": "Recuperatore 1 - Ventilazione - Velocità minima ventilatore ripresa"         },         {             "bus_datatype": "float16",             "datatype": "uint16",             "address": 3,             "units": "V",             "writable": true,             "type": "register",             "name": "Recuperatore 1 - Ventilazione - Velocità massima ventilatore ripresa"         },         {             "bus_datatype": "temperature",             "datatype": "int16",             "address": 15,             "units": "°C",             "writable": true,             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Regolazione - Setpoint temperatura"         },         {             "bus_datatype": "float16",             "datatype": "uint16",             "address": 16,             "units": "K",             "writable": true,             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Regolazione - Differenziale temperatura"         },         {             "bus_datatype": "temperature",             "datatype": "int16",             "address": 17,             "units": "°C",             "writable": true,             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Antigelo - Setpoint antigelo"         },         {             "bus_datatype": "float16",             "datatype": "uint16",             "address": 18,             "units": "K",             "writable": true,             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Antigelo - Differenziale antigelo"         },         {             "bus_datatype": "temperature",             "datatype": "int16",             "address": 19,             "units": "°C",             "writable": true,             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Sbrinamento - Setpoint sbrinamento"         },         {             "bus_datatype": "float16",             "datatype": "uint16",             "address": 20,             "units": "K",             "writable": true,             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Sbrinamento - Differenziale sbrinamento"         },         {             "bus_datatype": "float16",             "datatype": "int16",             "address": 21,             "units": "K",             "writable": true,             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Regolazione - Banda proporzionale caldo/freddo"         },         {             "value_custom": {                 "0": "Bassa",                 "1": "Media",                 "2": "Alta",                 "3": "Automatico",                 "default": "?"             },             "bus_datatype": "uint8",             "address": 22,             "datatype": "uint16",             "writable": true,             "type": "register",             "name": "Recuperatore 1 - Ventilazione - Set velocità ventilatore"         },         {             "datatype": "uint16",             "bus_datatype": "uint16",             "address": 24,             "type": "register",             "name": "Recuperatore 1 - Configurazione - Posizione DIP switch"         },         {             "bus_datatype": "temperature",             "address": 26,             "datatype": "int16",             "units": "°C",             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Temperature - Temperatura esterna"         },         {             "bus_datatype": "temperature",             "address": 27,             "datatype": "int16",             "units": "°C",             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Temperature - Temperatura aria immessa"         },         {             "bus_datatype": "temperature",             "address": 28,             "datatype": "int16",             "units": "°C",             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Temperature - Temperatura aria espulsa"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Filtri sporchi",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 128,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme filtri sporchi"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Allarme",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 1,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme sonda AI1"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Allarme",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 2,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme sonda AI2"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Allarme",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 4,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme sonda AI3"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Allarme",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 8,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme sonda AI4"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Allarme",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 16,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme sonda AI5"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Allarme",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 32,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme sonda P1"         },         {             "datatype": "uint16",             "value_custom": {                 "0": "Normale",                 "1": "Allarme",                 "default": "?"             },             "bus_datatype": "bool",             "address": 29,             "value_bitmask": 64,             "type": "register",             "name": "Recuperatore 1 - Allarmi - Allarme sonda P2"         },         {             "bus_datatype": "temperature",             "address": 30,             "datatype": "int16",             "units": "°C",             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Sonde opzionali - Temperatura P1"         },         {             "bus_datatype": "temperature",             "address": 31,             "datatype": "int16",             "units": "°C",             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Sonde opzionali - Temperatura P2"         },         {             "bus_datatype": "uint16",             "datatype": "uint16",             "address": 34,             "units": "ppm",             "writable": true,             "type": "register",             "name": "Recuperatore 1 - Qualità aria - Setpoint CO₂"         },         {             "value_custom": {                 "0": "Off",                 "1": "On",                 "default": "?"             },             "bus_datatype": "bool",             "address": 43,             "datatype": "uint16",             "writable": true,             "type": "register",             "name": "Recuperatore 1 - Comandi - On/Off da Modbus"         },         {             "read_swap": "n",             "bus_datatype": "temperature",             "address": 40056,             "datatype": "uint16",             "units": "°C",             "type": "register",             "value_multiplier": 0.1,             "name": "Recuperatore 1 - Temperature - Temperatura ambiente"         }     ] }

Wait, maybe I found the error, it has to be a holding register not an input register

No sorry, it is a holding


RE: Possible bug in modbus reading - admin - 17.09.2026

Provide the script that works for you. Have you disabled the script so that the mapper doesn't work in parallel? Check if you have any errors in Modbus tab error log.


RE: Possible bug in modbus reading - Ceros2112 - 17.09.2026

Yes, the script does not work right now, the device (through a TCP/RTU gateway) doesn't respond and goes straight to timeout

Code:
require('luamodbus') mb = luamodbus.tcp() mb:open('192.168.100.98', 502) mb:connect() mb:setslave(7) value, err = mb:readregisters(40056) log(value, err) mb:close()



RE: Possible bug in modbus reading - admin - 17.09.2026

Looks like the device has a low limit of open connections. Enable persistent mode in Modbus tab / device settings and try again. You might need to power cycle the device so it will start accepting connections faster.


RE: Possible bug in modbus reading - Ceros2112 - 17.09.2026

There it is another problem, it's a Modbus bridge (simply it passes messages between BMS and RTU devices) and I have to read 7 devices behind, so I can't use persistent mode i think


RE: Possible bug in modbus reading - admin - 17.09.2026

You can enable persistent mode for all devices connecting to the same IP. This way only a single connection will be used. You can also try increasing the timeout value.


RE: Possible bug in modbus reading - Ceros2112 - 17.09.2026

I tried, doesn't work


RE: Possible bug in modbus reading - admin - 18.09.2026

What about other devices connected to the same TCP/RTU gateway? Can you read them through LM correctly?


RE: Possible bug in modbus reading - Ceros2112 - 18.09.2026

Basically there are 7 identical devices, with the script (tested for only one register) there are some errors but I can read them correctly, with a profile containing only the same register I can't read them at all.


RE: Possible bug in modbus reading - admin - 18.09.2026

It seems to be a physical communication issue if you're saying that the script also produces errors from time to time. How long is the bus and what topology is used? Do you have 0V/GND connected between gateway and all Modbus devices?