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.

canX dali commands
#1
Hi
In case somebody want to use script to control canX DALI here are examples.
Code:
canxdali = require('applibs.canxdali')

canxdali.sendcmds(req)
  Sends single or multiple DALI commands to the given gateway.
  Returns number of bytes sent or nil plus error message.
  This is completely asynchronous function, it adds commands
  to gateway queue without waiting for returned results.

  req table:
    lineid - gateway line ID (number, required)
    nodeid - gateway node ID (number, required)

  command table:
    cmd - command name (string, required)
    value - command value (number, required for commands with a value)
    address - DALI address (string or number, required)
    addrtype - address type (string, required if address is a number)

  address format:
    address can be a string with following format:
      s0..s63 - short address, from 0 to 63
      g0..g15 - group, from 0 to 15
      b - broadcast

    if address is a number then addrtype is required, it can be either:
      short
      group
      broadcast

  Examples:

  Send arc with value 0 to DALI short address 15 using gateway 0.1:
    canxdali = require('applibs.canxdali')

    canxdali.sendcmds({
      lineid = 0,
      nodeid = 1,
      cmd = 'arc',
      address = 's15',
      value = 0,
    })

  Send multiple arc commands using gateway 1.42:
    canxdali = require('applibs.canxdali')

    canxdali.sendcmds({
      lineid = 1,
      nodeid = 42,
      cmds = {
        { cmd = 'arc', address = 's0', value = 50 },
        { cmd = 'arc', address = 's4', value = 10 },
      }
    })

canxdali.syncsendcmds(req)
  Similar to canxdali.sendcmds but waits for each command to complete.
  On success returns Lua table with each command result, nil plus error
  message otherwise.

canxdali.sendqueries(req)
  Similar to canxdali.syncsendcmds but checks for each command result,
  returns a table of values only for query type commands when all
  commands were successful. Useful for querying DALI device statuses.

canxdali.sethandler(type, fn)
  Sets a callback to execute on a specific event.
  Callback is executed for each command inside data frame separately.

  type - event type (string, required):
    bus - all commands coming from bus side
    busdata - only "bus data" type commands (from other master devices)
    all - all commands coming to/from bus
  fn - function to execute, or nil to remove callback (function or nil, required)

canxdali.step()
  Waits for a frame or timeout, whichever happens first.
  Returns frame or nil plus error message on timeout.
  Frame can contain multiple commands when sent to bus.

  Example (resident script):
    if not canxdali then
      function callback(frame)
        log(frame)
      end

      canxdali = require('applibs.canxdali')
      canxdali.sethandler('bus', callback)
    end

    canxdali.step()

------------------------------
Ctrl+F5
Reply


Messages In This Thread
canX dali commands - by Daniel - 13.12.2019, 14:08
RE: canX dali commands - by Oleg - 26.03.2020, 12:53
RE: canX dali commands - by Daniel - 26.03.2020, 13:40
RE: canX dali commands - by admin - 26.03.2020, 15:26
RE: canX dali commands - by Oleg - 26.03.2020, 15:46
RE: canX dali commands - by davidsilva - 24.11.2022, 15:22
RE: canX dali commands - by Daniel - 24.11.2022, 15:29
RE: canX dali commands - by admin - 24.11.2022, 16:30

Forum Jump: