Skip to content

Commit b5afa90

Browse files
committed
Merge branch 'release/0.1.0'
2 parents ec1f631 + 8df8b31 commit b5afa90

File tree

8 files changed

+146
-3
lines changed

8 files changed

+146
-3
lines changed

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,38 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
# Autotools
35+
# http://www.gnu.org/software/automake
36+
37+
Makefile.in
38+
/ar-lib
39+
/mdate-sh
40+
/py-compile
41+
/test-driver
42+
/ylwrap
43+
44+
# http://www.gnu.org/software/autoconf
45+
46+
/autom4te.cache
47+
/autoscan.log
48+
/autoscan-*.log
49+
/aclocal.m4
50+
/compile
51+
/config.guess
52+
/config.h.in
53+
/config.sub
54+
/configure
55+
/configure.scan
56+
/depcomp
57+
/install-sh
58+
/missing
59+
/stamp-h1
60+
61+
# https://www.gnu.org/software/libtool/
62+
63+
/ltmain.sh
64+
65+
# http://www.gnu.org/software/texinfo
66+
67+
/texinfo.tex

ChangeLog

Whitespace-only changes.

Makefile.am

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ACLOCAL_AMFLAGS = -I m4
2+
3+
libbyteconvert_subdirs=libbyteconvert
4+
5+
SUBDIRS=libbyteconvert

README.md

+68-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,68 @@
1-
# ByteConvert_cpp
2-
Library for C++ to convert variables to bytes and back
1+
# ByteConvert
2+
[![Build Status](https://travis-ci.org/SloCompTech/ByteConvert_cpp.svg?branch=master)](https://travis-ci.org/SloCompTech/ByteConvert_cpp)
3+
[![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)]()
4+
5+
## What's about ?
6+
Have you ever wanted to transmit `int`,`short`,`long`,`double` 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.
7+
8+
## What you need to consider, when you are using this library
9+
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.
10+
11+
## How to install
12+
```
13+
$ cd <library_directory>
14+
$ autoreconf -vis
15+
$ ./configure
16+
$ make
17+
$ make install
18+
```
19+
20+
If you have problems, that library can't be found run `sudo ldconfig`.
21+
22+
## Examples
23+
Convert numeric variable for eg. `int`,`short`,`float`,`double` to array of bytes.
24+
``` c++
25+
int somevar = 5;
26+
size_t blk_size = 0;
27+
uint8_t *block = ByteConvert::varToArray<int>(blk_size,somevar);
28+
29+
// Use array
30+
31+
delete block; // Don't forget to free memory, when you don't need array any more
32+
```
33+
34+
Convert array of bytes to numeric variable.
35+
``` c++
36+
uint8_t *block; // Predefined byte array with size of int
37+
int somevar = ByteConvert::arrayToVar<int>(block);
38+
39+
// Use block & somevar
40+
41+
delete block; // Don't forget to free memory, when you don't need array any more
42+
43+
// Use somevar
44+
```
45+
46+
Convert array of bytes to string of hex characters
47+
``` c++
48+
size_t blk_size; // Predefined size of byte array
49+
uint8_t *block; // Predefined byte array with size of int
50+
String somevar = ByteConvert::arrayToString(blk_size,block);
51+
52+
// Use block & somevar
53+
54+
delete block; // Don't forget to free memory, when you don't need array any more
55+
56+
// Use somevar
57+
```
58+
59+
Convert string of hex characters to array of bytes
60+
``` c++
61+
String somevar = ""; // Predefined string
62+
size_t blk_size = 0;
63+
uint8_t *block = ByteConvert::stringToArray(blk_size,somevar);
64+
65+
// Use block
66+
67+
delete block; // Don't forget to free memory, when you don't need array any more
68+
```

configure.ac

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
AC_INIT([libbyteconvert], [0.1.0], [[email protected]])
2+
3+
AC_CONFIG_MACRO_DIR([m4])
4+
5+
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
6+
LT_INIT
7+
8+
# Checks for programs.
9+
AC_PROG_CXX
10+
11+
# Checks for libraries.
12+
13+
# Checks for header files.
14+
AC_CHECK_HEADER([stdint.h],[],[AC_MSG_ERROR([sorry, can't do anything for you])])
15+
16+
# Checks for typedefs, structures, and compiler characteristics.
17+
AC_TYPE_SIZE_T
18+
AC_TYPE_UINT8_T
19+
20+
# Checks for library functions.
21+
AC_FUNC_MALLOC
22+
23+
# Config files
24+
AC_CONFIG_FILES([Makefile
25+
libbyteconvert/Makefile])
26+
27+
AC_OUTPUT

examples/SimpleTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <iostream>
22
#include <cstdlib>
3-
#include "../libbyteconvert/ByteConvert.hpp"
3+
#include <ByteConvert.hpp>
44

55
using namespace std;
66

libbyteconvert/Makefile.am

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
AM_CXXFLAGS = -std=c++11
2+
lib_LTLIBRARIES = libbyteconvert.la
3+
libbyteconvert_la_SOURCES = ByteConvert.cpp
4+
libbyteconvert_la_HEADERS = ByteConvert.hpp
5+
libbyteconvert_ladir = $(includedir)

m4/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# Ignore everything in this directory
3+
*
4+
# Except this file
5+
!.gitignore

0 commit comments

Comments
 (0)