Logic Machine Forum
localbus - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: localbus (/showthread.php?tid=2762)



localbus - benanderson_475 - 31.07.2020

hi , i am trying to work with localbus but i don't receive any logs from the groupcallback  function, i want to monitor several obj in a resident script.
in the attached i can see the handlers table but also udp{unconnected} maybe this is my problem ??

Code:
lb = require('localbus').new()

lb:sethandler('groupwrite', groupcallback)
lb:sethandler('groupread', groupcallback)
lb:sethandler('groupresponse', groupcallback)

log(lb)

function groupcallback(event) 
 
  log(event)
 
  if event.dst == '0/2/1' then   
    local value = knxdatatype.decode(event.datahex, dt.uint16)   
    log(value)
   
  end
end
many thanks


RE: localbus - fleeceable - 31.07.2020

Hi!
Does script engine gives you any errors?

Check that on error log...


RE: localbus - admin - 31.07.2020

You need to call step for it to receive data. You should also define callback before setting it.
Code:
if not lb then
  lb = require('localbus').new(1)

  function groupcallback(event)  
    log(event)
    
    if event.dst == '0/2/1' then    
      local value = knxdatatype.decode(event.datahex, dt.uint16)    
      log(value)
    end
  end

  lb:sethandler('groupwrite', groupcallback)
  lb:sethandler('groupread', groupcallback)
  lb:sethandler('groupresponse', groupcallback)
end

lb:step()



RE: localbus - benanderson_475 - 01.08.2020

(31.07.2020, 08:35)admin Wrote: You need to call step for it to receive data. You should also define callback before setting it.
Code:
if not lb then
  lb = require('localbus').new(1)

  function groupcallback(event) 
    log(event)
   
    if event.dst == '0/2/1' then   
      local value = knxdatatype.decode(event.datahex, dt.uint16)   
      log(value)
    end
  end

  lb:sethandler('groupwrite', groupcallback)
  lb:sethandler('groupread', groupcallback)
  lb:sethandler('groupresponse', groupcallback)
end

lb:step()
Many Thanks Smile