bofc manual pages




psmq-sub - helper tool to listen to subscribed messages over psmq.  


psmq-sub [ -h | -v ]
psmq-sub [<-n mqueue-name>] <-b name> <-t topic> [<-t topic>] [-o file]  


Prints short help and exits
Prints version information and exits
-n mqueue-name
psmq-sub will create and use to communicate with broker. This argument is optional and by default /psmq-sub will be used. If you want to use custom mqueue-name, then this argument must be the first one you pass.
-b name
mqueue name of the broker you want to use for communication. This options is mandatory and must be passed after (if set) -n argument and before -t.
-t topic
topic you want to subscribe to. At least one topic must be passed. You can subscribe to as many topics as you want by passing multiple -t options.
-o path
Path to a file, where logs from incoming messages shall be stored. If file cannot be opened, program will refuse to start. Optional argument, if not passed, messages will be printed to stdout.

Data will be printed in two ways depending on type of data received. When received data is simple ascii string, payload will be printed in the same line as info, thus one line per received message will be received. When data contains non-printable character, output will be hexdump like.

Line is printed in format:
p:n l:llll  topic  payload

is a priority number
number of bytes in payload, aligned to 4 numbers.
is a topic message was published on
received payload

Check following example to better understand the format. Output is a snippet from a source code, sixth line is printed in binary since it contains utf8 character which encoding contain non-printable charater. Rest of lines are printed in single line as a string.

p:0 l:  37  /msg        switch (psmqd_cfg_init(argc, argv))
p:0 l:   3  /msg        {
p:0 l:   9  /msg        case 0:
p:0 l:  37  /msg                /* no errors in parsing arguments,
p:0 l:  32  /msg                 * continue program execution
p:0 l:  40  /msg
0x0000  09 09 20 2a 20 75 74 66 2d 38 20 61 74 74 61 63  .. * utf-8 attac
0x0010  6b 2c 20 68 65 72 65 20 69 74 20 63 6f 6d 65 73  k, here it comes
0x0020  21 20 c5 82 20 2a 2f 00                          ! .. */.
p:0 l:   9  /msg                break;
p:0 l:   1  /msg
p:0 l:  10  /msg        case -2:
p:0 l:  10  /msg        case -3:
p:0 l:  39  /msg                /* help or version was printed, exit
p:0 l:  30  /msg                 * program without error */
p:0 l:  12  /msg                return 0;
p:0 l:   1  /msg
p:0 l:  10  /msg        default:
p:0 l:  32  /msg                /* error occured when parsing
p:0 l:  23  /msg                 * arguments, die */
p:0 l:  12  /msg                return 1;
p:0 l:   3  /msg        }

Log from different sensors may look like this

[2021-05-23 17:53:59] p:0 l:   3  /can/engine/rpm  50
[2021-05-23 17:53:59] p:0 l:   3  /adc/volt  30
[2021-05-23 17:53:59] p:0 l:   3  /can/room/10/temp  23


Listen to single topic
psmq-sub -b/brok -t/topic1
Listen on multiple topics, use custom mqueue name
psmq-sub -n/qsubnam -b/brok -t/topic1 -t/topic2/+ -t/topic3/subtopic2/*
Log every topic into file
psmq-sub -b/brok -t/* -o/var/log/psmq-log


Please, report all bugs to "Michał Łyszczek <>"  


psmqd(1), psmq-pub(1), psmq-sub(1), psmq_cleanup(3), psmq_init(3), psmq_publish(3), psmq_receive(3), psmq_subscribe(3), psmq_timedreceive(3), psmq_timedreceive_ms(3), psmq_unsubscribe(3), psmq_building(7), psmq_overview(7).

19 May 2021 (v9999)