• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ubus/lua/test_client.lua

  1 #!/usr/bin/env lua
  2 
  3 require "ubus"
  4 require "uloop"
  5 
  6 uloop.init()
  7 
  8 local conn = ubus.connect()
  9 if not conn then
 10         error("Failed to connect to ubusd")
 11 end
 12 
 13 local namespaces = conn:objects()
 14 for i, n in ipairs(namespaces) do
 15         print("namespace=" .. n)
 16         local signatures = conn:signatures(n)
 17         for p, s in pairs(signatures) do
 18                 print("\tprocedure=" .. p)
 19                 for k, v in pairs(s) do
 20                         print("\t\tattribute=" .. k .. " type=" .. v)
 21                 end
 22         end
 23 end
 24 
 25 local status = conn:call("test", "hello", { msg = "eth0" })
 26 
 27 for k, v in pairs(status) do
 28         print("key=" .. k .. " value=" .. tostring(v))
 29 end
 30 
 31 local status = {conn:call("test", "hello1", { msg = "eth0" })}
 32 
 33 for a = 1, #status do
 34         for k, v in pairs(status[a]) do
 35                 print("key=" .. k .. " value=" .. tostring(v))
 36         end
 37 end
 38 
 39 conn:send("test", { foo = "bar"})
 40 
 41 uloop.run()

This page was automatically generated by LXR 0.3.1.  •  OpenWrt