Explorar el Código

Merged in feature/PROTO-20-setup-arm-toolchain (pull request #9)

Feature/PROTO-20 setup arm toolchain
Bart Hertog hace 5 años
padre
commit
81ba365475
Se han modificado 3 ficheros con 46 adiciones y 26 borrados
  1. 3 2
      .gitignore
  2. 36 19
      README.md
  3. 7 5
      generator/protoc-gen-eams.py

+ 3 - 2
.gitignore

@@ -29,11 +29,12 @@ CMakeFiles/**
 # Ignore build results
 **/*.a
 build/
+*.bin
 
 # Ignore sonar scanner binaries
 sonar-scanner**
+build-wrapper**
+.sonarwork/
 
 # Ignore code coverage reports
 code_coverage_report/**
-examples/NUCLEO-F446RE/Debug/
-examples/NUCLEO-F446RE/Core/Inc/generated

+ 36 - 19
README.md

@@ -2,23 +2,30 @@
 ![alt text](https://embeddedams.nl/wp-content/uploads/2018/07/EmbeddedAMS_long.png "Embedded AMS Logo")
 
 
-Embedded AMS B.V. Amsterdam, [www.EmbeddedAMS.nl](https://www.EmbeddedAMS.nl), [info@EmbeddedAMS.nl](mailto:info@EmbeddedAMS.nl)
+Copyrichts 2020 Embedded AMS B.V. Amsterdam, [www.EmbeddedAMS.nl](https://www.EmbeddedAMS.nl), [info@EmbeddedAMS.nl](mailto:info@EmbeddedAMS.nl)
 
 
 # Introduction
 
-EmbeddedProto is a C++14 implementation of [Google Protocol Buffers](https://developers.google.com/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++](https://www.misra.org.uk/Activities/MISRAC/tabid/171/Default.aspx) guideline. 
+EmbeddedProto is a C++ implementation of [Google Protocol Buffers](https://developers.google.com/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 to make the code predictable. To further improte the realiability of the code it is automatically checked to be in line with the [MISRA C++](https://www.misra.org.uk/Activities/MISRAC/tabid/171/Default.aspx) 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.
+What are protocol buffers? Quoting from the [website](https://developers.google.com/protocol-buffers):
+> Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages
 
+In a .proto file you define the structure of your message. Next you use the protocol buffers compiler *protoc* to generate source code. This code you can use in your project. Protoc natively supports many differt programming languages. Your collegue working in a different language can thus use the same message structure. When one of you updates the structure just rerun *protoc* to get the latest source code.
 
-# Supported Features
+Natively however protocol buffers are not suitable for micro controllers. The C++ generated is written for server and desktop processors. This is where EmbeddedProto offers a alternative. EmbeddedProto is a plugin for *protoc* generating C++ code suitable for micro controllers. In this way EmbeddedProto provides an easy to use interface to exchange data between embedded devices and the out side world. Specifying the data format between your IOT device and other devices, servers, apps or desktop applications in a standardized way.
+
+This document details the following:
+* Supported Features
+* Installation
+* Usage
+* Development
 
-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.
+# Supported Features
+
+Below two tables are given indicating the level of support for various variable types and features.
 
 | Variable Type | Support |
 | --- | --- |
@@ -45,17 +52,23 @@ Other Messages | Full
 oneof | Full
 singular | Full
 repeated | Full
-maps | Under sonisderation
+maps | Under conisderation
 
+All features mentioned abover are of version 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 that EmbeddedProto will support proto2 in the future.
 
 # Installation
 
-What is required to be able to generate the source files:
+What is required to be able to generate source files based on .proto 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.
+1. Pip
+1. Virtualenv
+1. Protobuf 3.6.1
+1. Git if you do not have it already.
+1. CMake 3.10.2 (only required to build the PC unit tests)
+
+Install the required software and continue with checking out the repository. For PC unit testing gtest is used which is included as a submodule of this repository. If you intent to run the PC unit tests of EmbeddedProto it is suggested that you pull in the submodules as well. 
 
 ## 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. 
@@ -118,15 +131,19 @@ You can now use the Embedded Proto protoc plugin.
 At this time building the unit tests under Windows is not supported.
 
 
-# Normal Usage
+# 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:
+When working on your project you write your proto files defining the message structure. Next you 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:
 ```bash
-protoc --plugin=protoc-gen-eams -I./LOCATION/PROTO/FILES --eams_out=./build PROTO_MESSAGE_FILE.proto
+protoc --plugin=protoc-gen-eams -I./LOCATION/PROTO/FILES --eams_out=./generated_src 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.
+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 be parsed.
+
+As our plugin is a Python script and the protoc plugin should be an executable a small terminal script is included. This terminal script is called `protoc-gen-eams` and is used to execute python with the Embedded Proto python script as a parameter. The main take away is that this script should be accesable when running your protoc command.
+
+After running protoc without any errors the generated source code is located in the folder specified by `---eams_out`. This folder is to be included into your project. This is not the only folder to be included. The generated source files depend on other header and source files. These files can be found in `EmbeddedProto/src`. You are thus required to include this folder aswell in you toolchain. 
 
-As our plugin is a Python script and the protoc plugin should be an executable a small terminal script is included. This terminal 
+Various examples how to use and integrate EmbeddedProto in your project are given in: TODO
 
 
 # Development

+ 7 - 5
generator/protoc-gen-eams.py

@@ -261,7 +261,8 @@ class MessageTemplateParameters:
 def generate_code(request, respones):
     # Based upon the request from protoc generate
 
-    template_loader = jinja2.FileSystemLoader(searchpath="./generator/")
+    filepath = os.path.dirname(os.path.abspath(__file__))
+    template_loader = jinja2.FileSystemLoader(searchpath=filepath)
     template_env = jinja2.Environment(loader=template_loader, trim_blocks=True, lstrip_blocks=True)
     template_file = "Header_Template.h"
     template = template_env.get_template(template_file)
@@ -324,9 +325,10 @@ def main_plugin():
     data = io.open(sys.stdin.fileno(), "rb").read()
     request = plugin.CodeGeneratorRequest.FromString(data)
 
-    # Write the requests to a file for easy debugging.
-    with open("./debug_request.bin", 'wb') as file:
-        file.write(request.SerializeToString())
+    if '--debug' in sys.argv:
+        # Write the requests to a file for easy debugging.
+        with open("./debug_embbeded_proto.bin", 'wb') as file:
+            file.write(request.SerializeToString())
 
     # Create response
     response = plugin.CodeGeneratorResponse()
@@ -345,7 +347,7 @@ def main_cli():
     # The main function when running from the command line and debugging.  Instead of receiving data from protoc this
     # will read in a binary file stored the previous time main_plugin() is ran.
 
-    with open("debug_request.bin", 'rb') as file:
+    with open("debug_embbeded_proto.bin", 'rb') as file:
         data = file.read()
         request = plugin.CodeGeneratorRequest.FromString(data)