README.txt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is
  2. especially suitable for use in microcontrollers, but fits any memory
  3. restricted system.
  4. Homepage: http://kapsi.fi/~jpa/nanopb/
  5. Using the nanopb library
  6. ========================
  7. To use the nanopb library, you need to do two things:
  8. 1) Compile your .proto files for nanopb, using protoc.
  9. 2) Include pb_encode.c and pb_decode.c in your project.
  10. The easiest way to get started is to study the project in "examples/simple".
  11. It contains a Makefile, which should work directly under most Linux systems.
  12. However, for any other kind of build system, see the manual steps in
  13. README.txt in that folder.
  14. Using the Protocol Buffers compiler (protoc)
  15. ============================================
  16. The nanopb generator is implemented as a plugin for the Google's own protoc
  17. compiler. This has the advantage that there is no need to reimplement the
  18. basic parsing of .proto files. However, it does mean that you need the
  19. Google's protobuf library in order to run the generator.
  20. If you have downloaded a binary package for nanopb (either Windows, Linux or
  21. Mac OS X version), the 'protoc' binary is included in the 'generator-bin'
  22. folder. In this case, you are ready to go. Simply run this command:
  23. generator-bin/protoc --nanopb_out=. myprotocol.proto
  24. However, if you are using a git checkout or a plain source distribution, you
  25. need to provide your own version of protoc and the Google's protobuf library.
  26. On Linux, the necessary packages are protobuf-compiler and python-protobuf.
  27. On Windows, you can either build Google's protobuf library from source or use
  28. one of the binary distributions of it. In either case, if you use a separate
  29. protoc, you need to manually give the path to nanopb generator:
  30. protoc --plugin=protoc-gen-nanopb=nanopb/generator/protoc-gen-nanopb ...
  31. Running the tests
  32. =================
  33. If you want to perform further development of the nanopb core, or to verify
  34. its functionality using your compiler and platform, you'll want to run the
  35. test suite. The build rules for the test suite are implemented using Scons,
  36. so you need to have that installed. To run the tests:
  37. cd tests
  38. scons
  39. This will show the progress of various test cases. If the output does not
  40. end in an error, the test cases were successful.