Skip to content

Commit

Permalink
ubx-mq: show types in list command
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
  • Loading branch information
kmarkus committed Jul 21, 2020
1 parent c41eb95 commit a24c3b0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
6 changes: 4 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ This file tracks user visible API changes

## 0.9.1

- `ubx-mq`: add support for writing to mqueues. Example:
`ubx-mq write mymq "{0,0.01,0,0.1,0}" -r 0.1`
- `ubx-mq`
- add support for writing to mqueues. Example:
`ubx-mq write mymq "{0,0.01,0,0.1,0}" -r 0.1`
- show types in mq listing (this requires latest `uutils` v1.1.0.

- rtlog: init spinlock with `PTHREAD_PROCESS_SHARED`: cmdline tools
such as `ubx-mq` create processes and nodes that log to the same
Expand Down
32 changes: 26 additions & 6 deletions tools/ubx-mq
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ local function usage()
print([[
usage: ubx-mq <command> [<args>]
commands:
list list all ubx mqueues
read QUEUE read and output data of mq id QUEUE
write QUEUE VALUE write VALUE to mq QUEUE
-r RATE write at rate RATE instead of just once
list list all ubx mqueues
read MQ-ID read and output data of mqueue MQ-ID
write MQ-ID VALUE write VALUE to mq MQ-ID
-r RATE write at rate RATE instead of just once
global parameters:
-p m1,m2 list of modules to preload
Expand Down Expand Up @@ -191,9 +191,29 @@ end
local mqs = mqueues_get()

if opttab[0][1] == "list" then
for _,q in ipairs(mqs) do
print(fmt("%s %s %s", q.hashstr, utils.rpad(ts(q.data_len), 3), q.mq_id))
nd = ubx.node_create("ubx-mq", { loglevel=8})
ubx.load_module(nd, "stdtypes")
ubx.load_module(nd, "mqueue")

for _,m in ipairs(preloads) do
ubx.load_module(nd, m)
end

local outtab = utils.map(
function(t)
local typename
local typ = ubx.type_get_by_hashstr(nd, t.hashstr)
if typ ~= nil then
typename = ubx.safe_tostr(typ.name)
else
typename = "unknown"
end

return {t.mq_id, typename, ts(t.data_len), t.hashstr }
end, mqs)

utils.write_table(io.stdout, { "mq id", "type name", "array len", "type hash" }, outtab)

os.exit(0)

elseif opttab[0][1] == "read" then
Expand Down

0 comments on commit a24c3b0

Please sign in to comment.