DcclTool - GobySoft/goby GitHub Wiki
discussion for the blueprint https://blueprints.launchpad.net/dccl/+spec/dccl-tool
Rationale: Have a command line tool that can work with DCCL messages (analyze (for designing and inspection of sizes)/encode/decode).
To do
- Make binary format for encode/decode and maybe make it the default. 1. Decode can take 0-N -m flags to load various messages (or messages could be loaded by the .so) and then decode automatically based on the ID
Overview
dccl
- -e, --encode Encode a DCCL message to STDOUT from STDIN
- -d, --decode Decode a DCCL message to STDOUT from STDIN
- -a, --analyze Provides information on a given DCCL message definition (e.g. field sizes)
- -p, --display_proto Display the .proto definition of this message.
- -h, --help Gives help on the usage of 'dccl'
- -I, --proto_path Add another search directory for .proto files
- -l, --dlopen Open this shared library containing compiled DCCL messages.
- -m, --message Message name to encode, decode or analyze.
- -f, --proto_file .proto file to load.
- --format Format for encode output or decode input: 'hex' is ascii-encoded hexadecimal (default), 'textformat' is a Google Protobuf TextFormat byte string (i.e. output of DebugString()), 'base64' is ascii-encoded base 64.
Analyze
(show breakdown of field sizes, etc., similar to existing analyze_dccl tool):
dccl -a [-I /some/proto/path] -f file.proto
dccl -a -l libsomething.so -m ProtoMessageName
proto file
cd ~/dccl/3.0/src/test/dccl_header
dccl -a -f test.proto -I /home/toby/dccl/3.0/include
||||||| Dynamic Compact Control Language (DCCL) Codec |||||||
1 messages loaded.
Field sizes are in bits unless otherwise noted.
======================== GobyMessage ========================
Actual maximum size of message: 33 bytes / 264 bits
dccl.id head...........................8
user head............................166
body..................................88
padding to full byte...................2
Allowed maximum size of message: 64 bytes / 512 bits
--------------------------- Header ---------------------------
dccl.id head...................................8
GobyMessage..................................166
2. header............................166
10. time..............................17
20. time_signed.......................17
21. time_double.......................17
22. pasttime_double...................19
23. futuretime_double.................19
24. time_precision....................27
25. time_double_precision.............37
11. source_platform....................5
13. dest_type..........................2
14. dest_platform......................6
---------------------------- Body ----------------------------
GobyMessage.................................8-88
1. telegram.........................8-88
shared library
dccl -a -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck
||||||| Dynamic Compact Control Language (DCCL) Codec |||||||
1 messages loaded.
Field sizes are in bits unless otherwise noted.
============== goby.acomms.protobuf.NetworkAck ==============
Actual maximum size of message: 7 bytes / 56 bits
dccl.id head...........................8
user head.............................32
body..................................15
padding to full byte...................1
Allowed maximum size of message: 32 bytes / 256 bits
--------------------------- Header ---------------------------
dccl.id head...................................8
goby.acomms.protobuf.NetworkAck...............32
1. message_src.........................5
2. message_dest........................5
3. message_time.......................17
10. ack_src............................5
---------------------------- Body ----------------------------
goby.acomms.protobuf.NetworkAck...............15
4. message_dccl_id....................15
Encode
(hex ascii, base64 ascii, Protobuf TextFormat ascii)
echo "x: 23 y: 60 z: 57" | dccl -e -l libsomething.so -m ProtoMessageName --format=[textformat|hex|base64]
echo "x: 23 y: 60 z: 57" | dccl -e [-I /some/proto/path] -f file.proto -m ProtoMessageName --format=[textformat|hex|base64]
Example
*
echo "message_dccl_id: 2605 ack_src: 10 message_src: 4 message_dest: 2 message_time: 1389220739054210" | dccl -e --format=base64 -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck DGUQ+lwtCg==
*
echo "message_dccl_id: 2605 ack_src: 10 message_src: 4 message_dest: 2 message_time: 1389220739054210" | dccl -e -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck 0c6510fa5c2d0a
*
echo "message_dccl_id: 2605 ack_src: 10 message_src: 4 message_dest: 2 message_time: 1389220739054210" | dccl -e -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck --format=textformat "\014e\020\372\\-\n"
Decode
echo "0c6510fa5c2d0a" | dccl -d -l libsomething.so -m ProtoMessageName --format=hex
echo "DGUQ+lwtCg==" | dccl -d [-I /some/proto/path] file.proto -m ProtoMessageName --format=base64
echo "\014e\020\372\\-\n" | dccl -d -l libsomething.so -m ProtoMessageName --format=textformat
echo "x: 23 y: 60 z: 57" | dccl -e -l libsomething.so -m ProtoMessageName | dccl -d -l libsomething.so -m ProtoMessageName
Examples
*
echo "0c6510fa5c2d0a" | dccl -d -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck message_src: 4 message_dest: 2 message_time: 1389220739000000 message_dccl_id: 2605 ack_src: 10
*
echo "DGUQ+lwtCg==" | dccl -d -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck --format=base64 message_src: 4 message_dest: 2 message_time: 1389220739000000 message_dccl_id: 2605 ack_src: 10
*
(for i in 1 2 3 4 5; do echo "message_dccl_id: 2605 ack_src: $i message_src: 4 message_dest: 2 message_time: 1389220739054210" | dccl -e -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck --format=textformat; done) > test.txt cat test.txt | dccl -d -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck --format=textformat message_src: 4 message_dest: 2 message_time: 1389220739000000 message_dccl_id: 2605 ack_src: 1 message_src: 4 message_dest: 2 message_time: 1389220739000000 message_dccl_id: 2605 ack_src: 2 message_src: 4 message_dest: 2 message_time: 1389220739000000 message_dccl_id: 2605 ack_src: 3 message_src: 4 message_dest: 2 message_time: 1389220739000000 message_dccl_id: 2605 ack_src: 4 message_src: 4 message_dest: 2 message_time: 1389220739000000 message_dccl_id: 2605 ack_src: 5
test.txt :
"\014e\020\372\024-\n" "\014e\020\372\034-\n" "\014e\020\372$-\n" "\014e\020\372,-\n" "\014e\020\3724-\n"
*
(for i in 1 2 3 7 5; do echo "message_dccl_id: 2605 ack_src: $i message_src: 4 message_dest: 2 message_time: 1389220739054210"; done) | dccl -e -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck > test.txt && hexdump test.txt && cat test.txt | dccl -d -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck 0000000 650c fa10 2d14 0c0a 1065 1cfa 0a2d 650c 0000010 fa10 2d24 0c0a 1065 44fa 0a2d 650c fa10 0000020 2d34 000a 0000023 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 1 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 2 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 3 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 7 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 5
*
for j in "bin" "hex" "base64" "textformat"; do ((for i in 1 2 3 7 5; do echo "message_dccl_id: 2605 ack_src: $i message_src: 4 message_dest: 2 message_time: 1389220739054210"; done) | dccl -e --format=$j -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck > test.txt && cat test.txt && cat test.txt | dccl -d -l /home/toby/goby/2.1/lib/libgoby_acomms.so -m goby.acomms.protobuf.NetworkAck --format=$j); done e�- e� - e�$- e�D- e�4- message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 1 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 2 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 3 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 7 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 5 0c6510fa142d0a 0c6510fa1c2d0a 0c6510fa242d0a 0c6510fa442d0a 0c6510fa342d0a message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 1 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 2 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 3 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 7 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 5 DGUQ+hQtCg== DGUQ+hwtCg== DGUQ+iQtCg== DGUQ+kQtCg== DGUQ+jQtCg== message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 1 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 2 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 3 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 7 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 5 "\014e\020\372\024-\n" "\014e\020\372\034-\n" "\014e\020\372$-\n" "\014e\020\372D-\n" "\014e\020\3724-\n" message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 1 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 2 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 3 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 7 message_src: 4 message_dest: 2 message_time: 1398206339000000 message_dccl_id: 2605 ack_src: 5