You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
3.0 KiB

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