Нет описания

Bart Hertog c1cbf0ba5e Merged in develop (pull request #8) 5 лет назад
external 827a4a5be8 Added a readme in the submodule folder. 5 лет назад
generator 3c977f1075 Correcting typo's 5 лет назад
src 3c977f1075 Correcting typo's 5 лет назад
test 3c977f1075 Correcting typo's 5 лет назад
.gitignore da9be30ea7 Ignore build results and generated files. 6 лет назад
.gitmodules 3320cd8a42 Removed unused submodule protobuf 5 лет назад
CMakeLists.txt be72c64cc3 Initial gcov setup 6 лет назад
README.md 3c977f1075 Correcting typo's 5 лет назад
bitbucket-pipelines-dependencies.sh 3c977f1075 Correcting typo's 5 лет назад
bitbucket-pipelines.yml 4e322a398d Use the correct version of gcov 6 лет назад
build_test.sh 3c977f1075 Correcting typo's 5 лет назад
code_coverage.sh 3c977f1075 Correcting typo's 5 лет назад
gpl-3.0.txt 285d5fe40e Added the full liscense text of GPL V3.0 5 лет назад
protoc-gen-eams 3c977f1075 Correcting typo's 5 лет назад
protoc-gen-eams.bat 3c977f1075 Correcting typo's 5 лет назад
requirements.txt 916ce737f5 Added Jinja to the package requirements. 6 лет назад
sonar-project.properties 3c977f1075 Correcting typo's 5 лет назад
test_data.py 3c977f1075 Correcting typo's 5 лет назад

README.md

alt text

Embedded AMS B.V. Amsterdam, www.EmbeddedAMS.nl, info@EmbeddedAMS.nl

Introduction

EmbeddedProto is a C++14 implementation of Google Protocol Buffers dedicated for micro controllers. This means the implementation focuses on a small footprint and low memory usage. No dynamic memory allocation is used and the code is check to be in line with the MISRA C++ guideline.

In this way EmbeddedProto provides a very simple interface to exchange data between embedded devices and the out side world. Specifying the data format between your device and other devices, servers, apps or desktop applications is standardized and made simple.

Supported Features

All features mentioned below are proto3. At this moment proto2 is not supported. Taken from the Protobuf website:

Prefer proto3 While proto2 will continue to be supported, we encourage new codes to use proto3 instead, which is easier to use and supports more languages. For this reason it is unlikely we will support proto2 in the future.

Currently EmbeddedProto is work in progress. Below two tables are given indicating the level of support for various variable types and features.

Variable Type Support
double Full
float Full
int32 Full
int64 Full
uint32 Full
uint64 Full
sint32 Full
sint64 Full
fixed32 Full
fixed64 Full
sfixed32 Full
sfixed64 Full
bool Full
string Design phase
bytes Design phase
Feature Support
Enum Full
Other Messages Full
oneof Full
singular Full
repeated Full
maps Under sonisderation

Installation

What is required to be able to generate the source files:

  1. Python 3.6
  2. Pip
  3. Protobuf 3.6.1
  4. CMake 3.10.2 (optional to build PC unit tests)
  5. Git if you do not have it already.

Linux

Install the required software and continue with checking out the repository. For PC unit testing GTest is used which is included as a git submodule. If you intent to run the PC unit tests of EmbeddedProto it is suggested that you pull in the submodules as well.

git clone --recursive URL_TO_EMBEDDED_AMS

Next enter the folder and in that folder create a virtual environment called venv:

virtualenv venv

Activate the virtual environment

source ./venv/bin/activate

Besides the list of tools above additional python packages are required. These are listed in the requirements.txt file in this repository. It is advised to install these required packages using pip in a python virtenv. You can however install the requirements globally. To install the packages run the command:

pip install -r requirements.txt

You can now use the Embedded Proto protoc plugin in your projects. You are also ready to build the PC unit tests if you have installed CMake.

Windows

Clone the repository using your favourit git tool.

From the Protocol Buffers website download the desired release of protoc. Mind that the source is indicated with protobuf-XXX-A.B.C.zip. You are looking for protoc-A.B.C.-win64.zip. Unzip the file and install it according to the Readme file.

Next open up powershell and go to the EmbeddedProto folder.

cd C:\some\dir\embeddedproto

If not already installed, install virtualenv using pip3.

pip3 install virtualenv

Next create a virtual environment called venv:

virtualenv venv

Activate the virtual environment

.\venv\Scripts\activate

You should now see in your console the addition of (venv) in front of your location.

Next we will install all the python packages required for the plugin. These packages are contained by the virtualenv and will not interfere with other installations. The requirements file lists all packages to be installed using pip3.

pip3 install -r requirements.txt

You can now use the Embedded Proto protoc plugin.

At this time building the unit tests under Windows is not supported.

Normal Usage

When working on your project you write your proto files. Next the would like to use them in your source code. This requires you to generate the code based upon the definitions you have written. This is done using our plugin for the protoc compiler protoc-gen-eams.py. To generate the code use the following command:

protoc --plugin=protoc-gen-eams -I./LOCATION/PROTO/FILES --eams_out=./build PROTO_MESSAGE_FILE.proto

What happens is that protoc is toled to use our plugin with the option --plugin. Next the the standard option -I includes a folder where your *.proto files are located. The option --eams_out specifies the location where to store the generated source code. Finally a specific protofile is set to parse.

As our plugin is a Python script and the protoc plugin should be an executable a small terminal script is included. This terminal

Development

PC Unit Tests

The unit tests for PC are mend to test the logic of EmbeddedProto. The test are build upon the GTest and GMock libraries which are include as a submodule in this repository.

The tests are build using a small script in the root folder of the project:

./build_test.sh

This will:

  1. Generate message source files. The generated files are located in ./build/EAMS/.
  2. Compile GTest and GMock into ./build/google/.
  3. Build the unit tests into ./build/test.

To run the unit test execute:

./build/test/test_EmbeddedProto