2014-02-21

Protobuf for embedded

I have recently had the opportunity to research potential binary protocols at work. The thought just occurred to me that Google's protocol buffers (a.k.a. protobuf) might be a good candidate for the serial communication that occurs between different components such as controllers and servos.

You might think that it has too high overhead, and that may very well be the case. On the other hand protobuf has a few advantages that may not be obvious before you start using it.

For one, it makes thinking about your protocol much easier. The .proto text file format is just brilliant for recording your latest and greatest ideas for a protocol.

Second, you can actually use the code that is compiled by the protobuf compiler, not only for transfer of data, but also as your internal representation of the data. This will save memory, and that is good.

Third, it makes changing and even managing versions of your protocol effortless. For an embedded hardware project you might think that is unnecessary, but at least in my project with 36 servos with custom firmware and probably a whole bunch of other little controllers responsible for other stuff, with protobuf you could just change the .proto files, rebuild the firmware binary, upload it to the right controllers and be done.

I will investigate what impact protobuf has on the performance of tiny controllers, and on the bandwidth and latency of the serial communications, and report my findings here.

1 comment:

  1. Turns out google thought about this too!

    http://code.google.com/p/protobuf-embedded-c/

    ReplyDelete