berezovskyi / protobuf-embedded-c

Automatically exported from code.google.com/p/protobuf-embedded-c

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is Protobuf-Embedded-C ?

A protocol buffers generator for resource constrained embedded applications written in the C programming language.

For example, you may employ Protobuf-Embedded-C to let tiny embedded devices communicate directly with each other or with servers running large scale business applications.

These following guidelines drive Protobuf-Embedded-C:

  1. Generated C-code runs on low-power and low-memory embedded controllers.
  2. Generated C-code runs on real-time systems with static memory allocation.
  3. Code is completely generated, so it is self-contained (no libraries on the target device).
  4. API is easy to learn and (where possible) close to the concepts of the original protobuf implementations by Google.

Please note, that these guidelines imply reduced functionality, yet powerful enough to get the typical protobuf communication jobs done.

Publications

Wolfgang Schwitzer and Vlad Popa. Using Protocol Buffers for Resource-Constrained Distributed Embedded Systems. Technical Report TUM-I1120, Technische Universitaet Muenchen, 2011.

Examples

Writing the Proto File

//File: phone.proto
//
//Optional Embedded C internal options:
//@max_repeated_length=100
//@max_string_length=32

enum PhoneType {
  MOBILE = 0;
  HOME = 1;
  WORK = 2;
}

message PhoneNumber {
  required string number = 1;
  required PhoneType type = 2;
}

Compiling the Proto File

java -jar protoc-1.0M4.jar phone.proto

Be sure to have java (1.6), protoc-1.0M4.jar and phone.proto in your path.

Exploring the Generated API

Now, you should see the files phone.c and phone.h next to phone.proto, where phone.h provides you with the API to deal with PhoneNumber messages. The generated file phone.h will look similar like this:

/* Excerpt from generated file: phone.h */

#define MAX_REPEATED_LEN 100
#define MAX_STRING_LEN 32

enum PhoneType {
  _MOBILE = 0,
  _HOME = 1,
  _WORK = 2
};

#define MAX_PhoneNumber_SIZE 40

struct PhoneNumber {
  int _number_len;
  char _number[MAX_STRING_LEN];
  enum PhoneType _type;
};

int PhoneNumber_write_delimited_to(struct PhoneNumber *_PhoneNumber, void *_buffer, int offset);

int PhoneNumber_read_delimited_from(void *_buffer, struct PhoneNumber *_PhoneNumber, int offset);

Platform support

Protobuf-Embedded-C has been reported to run successfully on the following target platform so far: ARM Cortex M3, TI MSP430F5438, IA32 (in-the-loop tests).

Development environment

This page is intended for all developers, which want to maintain or extend the Protobuf-Embedded-C software.

About

Automatically exported from code.google.com/p/protobuf-embedded-c

License:Apache License 2.0


Languages

Language:C 40.3%Language:Java 24.2%Language:Xtend 23.9%Language:GAP 9.8%Language:Protocol Buffer 1.6%Language:Batchfile 0.2%