-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move ubus examples in ubus sub directory.
Signed-off-by: Jianhui Zhao <[email protected]>
- Loading branch information
Showing
2 changed files
with
34 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env eco | ||
|
||
local ubus = require 'eco.ubus' | ||
|
||
local attr_types = { | ||
[ubus.ARRAY] = 'Array', | ||
[ubus.TABLE] = 'Table', | ||
[ubus.STRING] = 'String', | ||
[ubus.INT64] = 'Integer', | ||
[ubus.INT32] = 'Integer', | ||
[ubus.INT16] = 'Integer', | ||
[ubus.INT8] = 'Boolean', | ||
[ubus.DOUBLE] = 'Number' | ||
} | ||
|
||
local con, err = ubus.connect() | ||
if not con then | ||
error(err) | ||
end | ||
|
||
for id, o in pairs(con:objects()) do | ||
print(string.format('"%s" @%08x', o, id)) | ||
for method, signature in pairs(con:signatures(o)) do | ||
io.write(string.format('\t"%s":{', method)) | ||
local comma = '' | ||
for k, v in pairs(signature) do | ||
io.write(string.format('%s"%s":"%s"', comma, k, attr_types[v] or 'unknown')) | ||
comma = ',' | ||
end | ||
print('}') | ||
end | ||
end | ||
|
||
con:close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters