fc42e76633148f8fce82f5be026896813e7f8fe6
[apps/agl-service-can-low-level.git] / README.md
1 Nanopb - Protocol Buffers for Embedded Systems
2 ==============================================
3
4 [![Build Status](https://travis-ci.org/nanopb/nanopb.svg?branch=master)](https://travis-ci.org/nanopb/nanopb)
5
6 Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is
7 especially suitable for use in microcontrollers, but fits any memory
8 restricted system.
9
10 * **Homepage:** http://kapsi.fi/~jpa/nanopb/
11 * **Downloads:** http://koti.kapsi.fi/~jpa/nanopb/download/
12 * **Forum:** https://groups.google.com/forum/#!forum/nanopb
13
14
15
16 Using the nanopb library
17 ------------------------
18 To use the nanopb library, you need to do two things:
19
20 1) Compile your .proto files for nanopb, using protoc.
21 2) Include pb_encode.c and pb_decode.c in your project.
22
23 The easiest way to get started is to study the project in "examples/simple".
24 It contains a Makefile, which should work directly under most Linux systems.
25 However, for any other kind of build system, see the manual steps in
26 README.txt in that folder.
27
28
29
30 Using the Protocol Buffers compiler (protoc)
31 --------------------------------------------
32 The nanopb generator is implemented as a plugin for the Google's own protoc
33 compiler. This has the advantage that there is no need to reimplement the
34 basic parsing of .proto files. However, it does mean that you need the
35 Google's protobuf library in order to run the generator.
36
37 If you have downloaded a binary package for nanopb (either Windows, Linux or
38 Mac OS X version), the 'protoc' binary is included in the 'generator-bin'
39 folder. In this case, you are ready to go. Simply run this command:
40
41     generator-bin/protoc --nanopb_out=. myprotocol.proto
42
43 However, if you are using a git checkout or a plain source distribution, you
44 need to provide your own version of protoc and the Google's protobuf library.
45 On Linux, the necessary packages are protobuf-compiler and python-protobuf.
46 On Windows, you can either build Google's protobuf library from source or use
47 one of the binary distributions of it. In either case, if you use a separate
48 protoc, you need to manually give the path to nanopb generator:
49
50     protoc --plugin=protoc-gen-nanopb=nanopb/generator/protoc-gen-nanopb ...
51
52
53
54 Running the tests
55 -----------------
56 If you want to perform further development of the nanopb core, or to verify
57 its functionality using your compiler and platform, you'll want to run the
58 test suite. The build rules for the test suite are implemented using Scons,
59 so you need to have that installed. To run the tests:
60
61     cd tests
62     scons
63
64 This will show the progress of various test cases. If the output does not
65 end in an error, the test cases were successful.
66
67 Note: Mac OS X by default aliases 'clang' as 'gcc', while not actually
68 supporting the same command line options as gcc does. To run tests on
69 Mac OS X, use: "scons CC=clang CXX=clang". Same way can be used to run
70 tests with different compilers on any platform.