Install tool software:
$ sudo apt-get install protoc // Generate .pb file from proto
$ sudo apt-get install python // Use official python The script generates the c and h files that can be used from the pb file
It is best to use the vi
compiler under linux
to write proto
File, the proto
file compiled in other compilation environments (such as the text editor of win
) may be converted into a c/h
file. The error is reported because of the encoding format. Some editing environments will have a special character at the beginning of the file, which may not be recognized.
Generate code
$ protoc -o message.pb message.proto
$ python nanopb/generator/nanopb_generator.py message.pb
Reference Article
nanopb protobuf study notes
Nanopb-protocol buffers with small code size
Using protobuf in embedded devices
Using protobuf in embedded devices
Protobuf installation and nanopb Simple examples
nanopb analysis and instructions for use