Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.
Actively maintained. Last release 7 days ago, commits in 14 of the last 26 weeks. A safe choice.
3 known vulnerabilities affect the latest version (0.4.9.3).
pip install nanopbNanopb - Protocol Buffers for Embedded Systems
Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.
- Homepage: https://jpa.kapsi.fi/nanopb/
- Git repository: https://github.com/nanopb/nanopb/
- Documentation: https://jpa.kapsi.fi/nanopb/docs/
- Forum: https://groups.google.com/forum/#!forum/nanopb
- Stable version downloads: https://jpa.kapsi.fi/nanopb/download/
- Pre-release binary packages: https://github.com/nanopb/nanopb/actions/workflows/binary_packages.yml
Using the nanopb library
To use the nanopb library, you need to do two things:
- Compile your .proto files for nanopb, using
protoc. - Include pb_encode.c, pb_decode.c and pb_common.c in your project.
The easiest way to get started is to study the project in "examples/simple". It contains a Makefile, which should work directly under most Linux systems. However, for any other kind of build system, see the manual steps in README.txt in that folder.
Generating the headers
Protocol Buffers messages are defined in a .proto file, which follows a standard
format that is compatible with all Protocol Buffers libraries. To use it with nanopb,
you need to generate .pb.c and .pb.h files from it:
python generator/nanopb_generator.py myprotocol.proto # For source checkout
generator-bin/nanopb_generator myprotocol.proto # For binary package
(Note: For instructions for nanopb-0.3.9.x and older, see the documentation of that particular version )