• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

.github/workflows/11-Mar-2024-674556

conan-wrapper/11-Mar-2024-85

docs/11-Mar-2024-7,4456,666

examples/11-Mar-2024-1,506953

extra/11-Mar-2024-885756

generator/11-Mar-2024-4,1243,184

spm-test/11-Mar-2024-1611

spm_headers/11-Mar-2024-1,353676

tests/11-Mar-2024-19,13314,633

tools/11-Mar-2024-15867

zephyr/11-Mar-2024-54

.gitignoreD11-Mar-2024553 3433

AUTHORS.txtD11-Mar-20244.6 KiB124123

BUILD.bazelD11-Mar-20242.2 KiB9381

CHANGELOG.txtD11-Mar-202427.1 KiB598533

CMakeLists.txtD11-Mar-20244.8 KiB144122

CONTRIBUTING.mdD11-Mar-20241.2 KiB3321

LICENSE.txtD11-Mar-2024898 2115

Package.swiftD11-Mar-20241.4 KiB6457

README.mdD11-Mar-20244.3 KiB10073

WORKSPACED11-Mar-2024499 2313

build.pyD11-Mar-2024205 75

conanfile.pyD11-Mar-2024966 3429

library.jsonD11-Mar-20241.1 KiB4443

pb.hD11-Mar-202442.7 KiB915530

pb_common.cD11-Mar-202411.9 KiB389287

pb_common.hD11-Mar-20241.6 KiB5020

pb_decode.cD11-Mar-202452.5 KiB1,7281,292

pb_decode.hD11-Mar-20247.2 KiB19463

pb_encode.cD11-Mar-202429.6 KiB1,001763

pb_encode.hD11-Mar-20246.8 KiB18659

README.md

1Nanopb - Protocol Buffers for Embedded Systems
2==============================================
3
4![Latest change](https://github.com/nanopb/nanopb/actions/workflows/trigger_on_code_change.yml/badge.svg)
5![Weekly build](https://github.com/nanopb/nanopb/actions/workflows/trigger_on_schedule.yml/badge.svg)
6
7Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is
8especially suitable for use in microcontrollers, but fits any memory
9restricted system.
10
11* **Homepage:** https://jpa.kapsi.fi/nanopb/
12* **Git repository:** https://github.com/nanopb/nanopb/
13* **Documentation:** https://jpa.kapsi.fi/nanopb/docs/
14* **Forum:** https://groups.google.com/forum/#!forum/nanopb
15* **Stable version downloads:** https://jpa.kapsi.fi/nanopb/download/
16* **Pre-release binary packages:** https://github.com/nanopb/nanopb/actions/workflows/binary_packages.yml
17
18
19Using the nanopb library
20------------------------
21To use the nanopb library, you need to do two things:
22
231. Compile your .proto files for nanopb, using `protoc`.
242. Include *pb_encode.c*, *pb_decode.c* and *pb_common.c* in your project.
25
26The easiest way to get started is to study the project in "examples/simple".
27It contains a Makefile, which should work directly under most Linux systems.
28However, for any other kind of build system, see the manual steps in
29README.txt in that folder.
30
31
32Generating the headers
33----------------------
34Protocol Buffers messages are defined in a `.proto` file, which follows a standard
35format that is compatible with all Protocol Buffers libraries. To use it with nanopb,
36you need to generate `.pb.c` and `.pb.h` files from it:
37
38    python generator/nanopb_generator.py myprotocol.proto  # For source checkout
39    generator-bin/nanopb_generator myprotocol.proto        # For binary package
40
41(Note: For instructions for nanopb-0.3.9.x and older, see the documentation
42of that particular version [here](https://github.com/nanopb/nanopb/blob/maintenance_0.3/README.md))
43
44The binary packages for Windows, Linux and Mac OS X should contain all necessary
45dependencies, including Python, python-protobuf library and protoc. If you are
46using a git checkout or a plain source distribution, you will need to install
47Python separately. Once you have Python, you can install the other dependencies
48with `pip install --upgrade protobuf grpcio-tools`.
49
50You can further customize the header generation by creating an `.options` file.
51See [documentation](https://jpa.kapsi.fi/nanopb/docs/concepts.html#modifying-generator-behaviour) for details.
52
53
54Running the tests
55-----------------
56If you want to perform further development of the nanopb core, or to verify
57its functionality using your compiler and platform, you'll want to run the
58test suite. The build rules for the test suite are implemented using Scons,
59so you need to have that installed (ex: `sudo apt install scons` or `pip install scons`).
60To run the tests:
61
62    cd tests
63    scons
64
65This will show the progress of various test cases. If the output does not
66end in an error, the test cases were successful.
67
68Note: Mac OS X by default aliases 'clang' as 'gcc', while not actually
69supporting the same command line options as gcc does. To run tests on
70Mac OS X, use: `scons CC=clang CXX=clang`. Same way can be used to run
71tests with different compilers on any platform.
72
73For embedded platforms, there is currently support for running the tests
74on STM32 discovery board and [simavr](https://github.com/buserror/simavr)
75AVR simulator. Use `scons PLATFORM=STM32` and `scons PLATFORM=AVR` to run
76these tests.
77
78
79Build systems and integration
80-----------------------------
81Nanopb C code itself is designed to be portable and easy to build
82on any platform. Often the bigger hurdle is running the generator which
83takes in the `.proto` files and outputs `.pb.c` definitions.
84
85There exist build rules for several systems:
86
87* **Makefiles**: `extra/nanopb.mk`, see `examples/simple`
88* **CMake**: `extra/FindNanopb.cmake`, see `examples/cmake`
89* **SCons**: `tests/site_scons` (generator only)
90* **Bazel**: `BUILD` in source root
91* **Conan**: `conanfile.py` in source root
92* **PlatformIO**: https://platformio.org/lib/show/431/Nanopb
93* **PyPI/pip**: https://pypi.org/project/nanopb/
94* **vcpkg**: https://vcpkg.info/port/nanopb
95
96And also integration to platform interfaces:
97
98* **Arduino**: http://platformio.org/lib/show/1385/nanopb-arduino
99
100