LibMISB - Examples - Library basic usage

From RidgeRun Developer Wiki
Revision as of 18:17, 20 June 2022 by Cleahy (talk | contribs)




Previous: Getting_Started/How_to_compile Index  






Testing library

This library has an example that you can execute. This example is a metadata converter that can encode or decode metadata. If you want to encode, the input file must respect one of the formats developed (for this first version, only could use JSON format) and will return a binary file with metadata encoded. On the other hand, if you want to decode the program receives a binary file and converts it to the format file selected (for this first version, only could use JSON format).

The executable is located on /misb-library/examples/misb/ or if you want to compile and execute the example file out of the project. The path of the example is located on /misb-library/examples/misb/misb-converter.cpp. To compile the example we suggest you follow the next Makefile:

FLAGS:=`pkg-config --cflags --libs misb-0.0`
misb-converter: misb-converter.cpp
	g++ -o misb-converter misb-converter.cpp $(FLAGS)

Encode command

To perform the encoding, the following command is executed. Where the --encode flag indicates that encoding is to be performed. The -i flag indicates the input file, where the metadata must be raw without encoding. On the other hand, the -o flag indicates the output file, which contains the encoded bytes in a binary file. The --verbose flag shows the KLV bytes encoded on the terminal.

./misb-converter --verbose --encode -i misb_ST0601_sample.json -o klv.bin

Decode command

To perform the decoding, the following command is executed. Where the --decode flag indicates that decoding is to be performed. The -i flag indicates the input file, where the metadata must be encoded. The -o flag indicates the output file, which contains the metadata decoded.

./misb-converter --decode -i klv.bin -o output.json