Jump to content

LibMISB/Examples/Library basic usage: Difference between revisions

no edit summary
No edit summary
Line 6: Line 6:




== 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).


== Dependencies ==
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:  
Your build environment will need the following packages installed in order to build LibMISB:  
<syntaxhighlight lang=Makefile>
* jansson
FLAGS:=`pkg-config --cflags --libs misb-0.0`
* cpputest
misb-converter: misb-converter.cpp
* doxygen
g++ -o misb-converter misb-converter.cpp $(FLAGS)
* meson
 
== Apt Get Installation ==
<syntaxhighlight lang=bash>
sudo apt-get install \
libjansson-dev \
cpputest \
doxygen \
python3 \
python3-pip \
ninja-build
</syntaxhighlight>
</syntaxhighlight>


== Meson Installation ==
=== Encode command ===
Follow the next command to install Meson:
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.


<syntaxhighlight lang=bash>
<syntaxhighlight lang=C>
pip3 install --user 'meson<=0.60.3' --force-reinstall
./misb-converter --verbose --encode -i misb_ST0601_sample.json -o klv.bin
</syntaxhighlight>
</syntaxhighlight>


If meson doesn't work, try reboot.
=== Decode command ===
Important: Meson version must be less or equal to 0.60.3. You can verify Meson version with the following 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.
 
<syntaxhighlight lang=bash>
meson --version
</syntaxhighlight>
 
== LibMISB ==
LibMISB is a [https://mesonbuild.com/ Meson] project. This makes it easy to build software packages for a variety of operating systems and platforms, including embedded devices.
=== '''Building LibMISB''' ===
 
You can run the following commands:
<syntaxhighlight lang=bash>
meson builddir
ninja -C builddir
</syntaxhighlight>
 
Specify meson --prefix $INSTALL_PATH build, if you want the build to be configured for installation in a directory other than /usr/local.
 
== '''Installing the Binaries''' ==
Once the ninja -C build commands completes, you can install the generated binaries:
<syntaxhighlight lang=bash>
ninja -C builddir install
</syntaxhighlight>


If you are trying to install to a system location you will need to run with sudo privileges.
<syntaxhighlight lang=C>
<syntaxhighlight lang=bash>
./misb-converter --decode -i klv.bin -o output.json
sudo ninja -C builddir install
</syntaxhighlight>
</syntaxhighlight>
267

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.