![]() |
|
Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - 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: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) (/showthread.php?tid=6565) |
Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - JuLopez - 23.09.2026 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)
endLog: 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 frameSecond 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))
endLog 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. RE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - Daniel - 23.09.2026 on SE hw port is /dev/RS485 not /dev/RS485-1 RE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - JuLopez - 23.09.2026 (Yesterday, 11:00)Daniel Wrote: on SE hw port is /dev/RS485 not /dev/RS485-1 Modify to RS485 instead of RS485-1 in: Code: -- load mbus library
require('mbus')
-- use /dev/RS485 serial port with 2400 baud rate
mbus.init('/dev/RS485', 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))
endThe error log is still givinng me: Code: Test Modbus 12.09.2026 12:48:35
User script:6: attempt to index global 'event' (a nil value)
stack traceback:RE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - admin - 23.09.2026 Script must be an event script mapped to a 1-byte unsigned object. RE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - JuLopez - 23.09.2026 (Yesterday, 11:11)admin Wrote: Script must be an event script mapped to a 1-byte unsigned object. Run scann script on the 1-byte unsigned object, the log: Code: Test ModBUs 12.09.2026 12:55:24
* arg: 1
* nil
* arg: 2
* string: cannot open port(Yesterday, 11:15)JuLopez Wrote:(Yesterday, 11:11)admin Wrote: Script must be an event script mapped to a 1-byte unsigned object. And with /dev/RS485-1 the log is: Code: Test ModBUs 12.09.2026 12:59:05
* arg: 1
* nil
* arg: 2
* string: no replyRE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - admin - 23.09.2026 What firmware and hardware version do you have? RE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - JuLopez - 23.09.2026 (Yesterday, 11:22)admin Wrote: What firmware and hardware version do you have? homeLYnk: FlashSYS v2 HW: LM5 Lite (i.MX28) FlashSYS v2
RE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - Daniel - 23.09.2026 You can stop testing, this will never work. By flashing our firmware you completely disabled RS port. Plus this hw is EOL and no longer supported. RE: Integration Between AFD WEB (RS485) + homeLYnk (ModBus) - JuLopez - 23.09.2026 (Yesterday, 11:36)Daniel Wrote: You can stop testing, this will never work. By flashing our firmware you completely disabled RS port. okay, thank you |