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
#2
on SE hw port is /dev/RS485 not /dev/RS485-1
------------------------------
Ctrl+F5
Reply
#3
(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)) end

The 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:
Reply
#4
Script must be an event script mapped to a 1-byte unsigned object.
Reply
#5
(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.

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

And with /dev/RS485-1 the log is:
Code:
Test ModBUs 12.09.2026 12:59:05 * arg: 1   * nil * arg: 2   * string: no reply
Reply
#6
What firmware and hardware version do you have?
Reply
#7
(Yesterday, 11:22)admin Wrote: What firmware and hardware version do you have?

homeLYnk: FlashSYS v2
HW: LM5 Lite (i.MX28)

FlashSYS v2
Reply
#8
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.
------------------------------
Ctrl+F5
Reply
#9
(Yesterday, 11:36)Daniel Wrote: 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.

okay, thank you
Reply


Forum Jump: