Have you ever wanted to transmit int
,short
,long
or any other numeric type over I2C,SPI,serial or other protocol or bus, but you converted variable to string to be able to transmit it char by char. This library enables you to convert any numeric value to bytes or other way around and you can also print array of bytes.
When you are using this library, you need to consider variable byte size, because if you are using different platforms, then there may be some errors, because int on platform 1 has 4 bytes and int on platform 2 may has 2 bytes.
You need python3, ninja and meson.
sudo apt-get install python3 python3-pip ninja-build
sudo pip3 install meson
meson build
ninja -C build
ninja -C build test
ninja -C build install
# Or simply
make
sudo make install
If you have problems, that library can't be found run sudo ldconfig /usr/local/lib/x86_64-linux-gnu/
if you haven't changed prefix, else modify path.
It's simple. At the top of your source file include library:
#include <ByteConvert/ByteConvert.hpp>
And when you compile add flag -lbyteconvert
, example g++ -std=c++11 MyProject.cpp -lbyteconvert -o MyProject
.
See examples folder