Giter VIP home page Giter VIP logo

protobuf-embedded-c's Introduction

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.

protobuf-embedded-c's People

Contributors

nvpopa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.