This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Integration Between AFD WEB (RS485) + homeLYnk (ModBus)
#1
Good morning, community,

I hope you are all doing well. I would like to ask for some help regarding a gateway. I have a converter device—the ADF WEB HD67022-B2-20—with a Zenner meter (M-Bus) connected to the upper terminal, while the lower terminals (RS485) are connected to the homeLYnk server via the Modbus port.
 

The ADF configurations were set up on the SW67021 with the following parameters:
  baudrate = 2400,
  parity = 'even',
  databits = 8,
  stopbits = 1,
I have two scanning scripts, but neither returns the Zenner meter reading table.

First script:

Code:
local serial = require('serial') local mbus = require('mbus') -- 1. Forzamos la apertura manual del puerto físico controlando los parámetros exactos -- Probaremos con '/dev/RS485-1' (si da error al abrir, cámbialo por '/dev/ttyS1' o '/dev/RS485') local port_path = '/dev/RS485-1' local port = serial.open(port_path, {   baudrate = 2400,   parity = 'even',   databits = 8,   stopbits = 1,   duplex = 'half' -- CRÍTICO para que los bornes físicos conmuten entre hablar y escuchar }) if port then   log('Puerto físico abierto manualmente con control de flujo.')     -- 2. Inicializamos el mbus pasándole el OBJETO ya configurado y abierto   -- Para saltar el bug de tu firmware, usamos pcall.   -- Si mbus.init(port) fallaba, probamos a inicializar pasándole los parámetros explícitos:   pcall(function()     mbus.init(port_path, 2400, "half")   end)   -- 3. Lanzamos la petición al contador 26   local direccion_contador = 26   local res, read_err = mbus.getdata(direccion_contador)   if res then     log('¡CONECTADO CON ÉXITO! Datos:')     log(res)   else     log('Error en dirección ' .. direccion_contador .. ': ' .. tostring(read_err))   end   port:close() else   log('No se pudo abrir manualmente el puerto ' .. port_path) end

Log:

Code:
+mbus 12.09.2026 12:35:06 * string: Puerto físico abierto manualmente con control de flujo. +mbus 12.09.2026 12:35:10 * string: Error en dirección 26: failed to send/receive frame


Second script:


Code:
-- load mbus library require('mbus') -- use /dev/RS232 serial port with 2400 baud rate mbus.init('/dev/RS485-1', 2400) -- new address to write addr = event.getvalue() -- change short address from default 0 to new one res, err = mbus.writeaddr(0, addr) -- change ok if res then   alert('[mbus] changed short address to' .. addr) -- change failed else   alert('[mbus] failed to change short address to ' .. addr .. ' ' .. tostring(err)) end


Log Error:


Code:
User script:6: attempt to index global 'event' (a nil value) stack traceback:


Do you happen to have any information about this? I appreciate your help in advance.
Reply


Messages In This Thread
Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - by JuLopez - Yesterday, 10:57

Forum Jump: