Add 'can-config-generator/' from commit 'b7591d16c2686214d5d8dcc0739a233f15aee5db'
authorRomain Forlot <romain.forlot@iot.bzh>
Tue, 11 Apr 2017 13:49:47 +0000 (15:49 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Tue, 11 Apr 2017 13:49:47 +0000 (15:49 +0200)
git-subtree-dir: can-config-generator
git-subtree-mainline: 9e444ade872bc436cf12bc12d03c3a5d51ac0b9e
git-subtree-split: b7591d16c2686214d5d8dcc0739a233f15aee5db

28 files changed:
1  2 
can-config-generator/.gitignore
can-config-generator/3rdparty/json/json.hpp
can-config-generator/CMakeLists.txt
can-config-generator/LICENSE
can-config-generator/README.md
can-config-generator/build.sh
can-config-generator/can-config-generator.sln
can-config-generator/can-config-generator.vcxproj
can-config-generator/src/main.cpp
can-config-generator/src/main.hpp
can-config-generator/src/openxc/can_bus.cpp
can-config-generator/src/openxc/can_bus.hpp
can-config-generator/src/openxc/can_message.cpp
can-config-generator/src/openxc/can_message.hpp
can-config-generator/src/openxc/command.cpp
can-config-generator/src/openxc/command.hpp
can-config-generator/src/openxc/diagnostic_message.cpp
can-config-generator/src/openxc/diagnostic_message.hpp
can-config-generator/src/openxc/mapping.cpp
can-config-generator/src/openxc/mapping.hpp
can-config-generator/src/openxc/message_set.cpp
can-config-generator/src/openxc/message_set.hpp
can-config-generator/src/openxc/signal.cpp
can-config-generator/src/openxc/signal.hpp
can-config-generator/tests/basic.json
can-config-generator/tests/generated.cpp
can-config-generator/tests/handlers.cpp
can-config-generator/tests/signals.json

index 0000000,0000000..1d26455
new file mode 100755 (executable)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,8 @@@
++.vs/\r
++.vscode/\r
++.kdev4/\r
++build*/\r
++*.kdev4\r
++bin/\r
++*.vcxproj.user\r
++obj/\r
index 0000000,6dfc183..6dfc183
mode 000000,100755..100755
--- /dev/null
index 0000000,0000000..8eb40d5
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,27 @@@
++cmake_minimum_required(VERSION 3.3)\r
++project(can-config-generator)\r
++\r
++if (CMAKE_VERSION VERSION_LESS "3.1")\r
++      if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")\r
++              set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")\r
++      elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")\r
++              set (CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}")\r
++      endif ()\r
++else ()\r
++      set (CMAKE_CXX_STANDARD 11)\r
++endif ()\r
++\r
++include_directories(SYSTEM 3rdparty/json)\r
++\r
++add_executable(can-config-generator\r
++      src/main.cpp\r
++      src/openxc/message_set.cpp\r
++      src/openxc/can_bus.cpp\r
++      src/openxc/can_message.cpp\r
++      src/openxc/command.cpp\r
++      src/openxc/diagnostic_message.cpp\r
++      src/openxc/mapping.cpp\r
++      src/openxc/signal.cpp)\r
++\r
++target_link_libraries(can-config-generator)\r
++target_compile_features(can-config-generator PRIVATE cxx_range_for cxx_constexpr cxx_nullptr)\r
index 0000000,0000000..8dada3e
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,201 @@@
++                                 Apache License
++                           Version 2.0, January 2004
++                        http://www.apache.org/licenses/
++
++   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
++
++   1. Definitions.
++
++      "License" shall mean the terms and conditions for use, reproduction,
++      and distribution as defined by Sections 1 through 9 of this document.
++
++      "Licensor" shall mean the copyright owner or entity authorized by
++      the copyright owner that is granting the License.
++
++      "Legal Entity" shall mean the union of the acting entity and all
++      other entities that control, are controlled by, or are under common
++      control with that entity. For the purposes of this definition,
++      "control" means (i) the power, direct or indirect, to cause the
++      direction or management of such entity, whether by contract or
++      otherwise, or (ii) ownership of fifty percent (50%) or more of the
++      outstanding shares, or (iii) beneficial ownership of such entity.
++
++      "You" (or "Your") shall mean an individual or Legal Entity
++      exercising permissions granted by this License.
++
++      "Source" form shall mean the preferred form for making modifications,
++      including but not limited to software source code, documentation
++      source, and configuration files.
++
++      "Object" form shall mean any form resulting from mechanical
++      transformation or translation of a Source form, including but
++      not limited to compiled object code, generated documentation,
++      and conversions to other media types.
++
++      "Work" shall mean the work of authorship, whether in Source or
++      Object form, made available under the License, as indicated by a
++      copyright notice that is included in or attached to the work
++      (an example is provided in the Appendix below).
++
++      "Derivative Works" shall mean any work, whether in Source or Object
++      form, that is based on (or derived from) the Work and for which the
++      editorial revisions, annotations, elaborations, or other modifications
++      represent, as a whole, an original work of authorship. For the purposes
++      of this License, Derivative Works shall not include works that remain
++      separable from, or merely link (or bind by name) to the interfaces of,
++      the Work and Derivative Works thereof.
++
++      "Contribution" shall mean any work of authorship, including
++      the original version of the Work and any modifications or additions
++      to that Work or Derivative Works thereof, that is intentionally
++      submitted to Licensor for inclusion in the Work by the copyright owner
++      or by an individual or Legal Entity authorized to submit on behalf of
++      the copyright owner. For the purposes of this definition, "submitted"
++      means any form of electronic, verbal, or written communication sent
++      to the Licensor or its representatives, including but not limited to
++      communication on electronic mailing lists, source code control systems,
++      and issue tracking systems that are managed by, or on behalf of, the
++      Licensor for the purpose of discussing and improving the Work, but
++      excluding communication that is conspicuously marked or otherwise
++      designated in writing by the copyright owner as "Not a Contribution."
++
++      "Contributor" shall mean Licensor and any individual or Legal Entity
++      on behalf of whom a Contribution has been received by Licensor and
++      subsequently incorporated within the Work.
++
++   2. Grant of Copyright License. Subject to the terms and conditions of
++      this License, each Contributor hereby grants to You a perpetual,
++      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
++      copyright license to reproduce, prepare Derivative Works of,
++      publicly display, publicly perform, sublicense, and distribute the
++      Work and such Derivative Works in Source or Object form.
++
++   3. Grant of Patent License. Subject to the terms and conditions of
++      this License, each Contributor hereby grants to You a perpetual,
++      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
++      (except as stated in this section) patent license to make, have made,
++      use, offer to sell, sell, import, and otherwise transfer the Work,
++      where such license applies only to those patent claims licensable
++      by such Contributor that are necessarily infringed by their
++      Contribution(s) alone or by combination of their Contribution(s)
++      with the Work to which such Contribution(s) was submitted. If You
++      institute patent litigation against any entity (including a
++      cross-claim or counterclaim in a lawsuit) alleging that the Work
++      or a Contribution incorporated within the Work constitutes direct
++      or contributory patent infringement, then any patent licenses
++      granted to You under this License for that Work shall terminate
++      as of the date such litigation is filed.
++
++   4. Redistribution. You may reproduce and distribute copies of the
++      Work or Derivative Works thereof in any medium, with or without
++      modifications, and in Source or Object form, provided that You
++      meet the following conditions:
++
++      (a) You must give any other recipients of the Work or
++          Derivative Works a copy of this License; and
++
++      (b) You must cause any modified files to carry prominent notices
++          stating that You changed the files; and
++
++      (c) You must retain, in the Source form of any Derivative Works
++          that You distribute, all copyright, patent, trademark, and
++          attribution notices from the Source form of the Work,
++          excluding those notices that do not pertain to any part of
++          the Derivative Works; and
++
++      (d) If the Work includes a "NOTICE" text file as part of its
++          distribution, then any Derivative Works that You distribute must
++          include a readable copy of the attribution notices contained
++          within such NOTICE file, excluding those notices that do not
++          pertain to any part of the Derivative Works, in at least one
++          of the following places: within a NOTICE text file distributed
++          as part of the Derivative Works; within the Source form or
++          documentation, if provided along with the Derivative Works; or,
++          within a display generated by the Derivative Works, if and
++          wherever such third-party notices normally appear. The contents
++          of the NOTICE file are for informational purposes only and
++          do not modify the License. You may add Your own attribution
++          notices within Derivative Works that You distribute, alongside
++          or as an addendum to the NOTICE text from the Work, provided
++          that such additional attribution notices cannot be construed
++          as modifying the License.
++
++      You may add Your own copyright statement to Your modifications and
++      may provide additional or different license terms and conditions
++      for use, reproduction, or distribution of Your modifications, or
++      for any such Derivative Works as a whole, provided Your use,
++      reproduction, and distribution of the Work otherwise complies with
++      the conditions stated in this License.
++
++   5. Submission of Contributions. Unless You explicitly state otherwise,
++      any Contribution intentionally submitted for inclusion in the Work
++      by You to the Licensor shall be under the terms and conditions of
++      this License, without any additional terms or conditions.
++      Notwithstanding the above, nothing herein shall supersede or modify
++      the terms of any separate license agreement you may have executed
++      with Licensor regarding such Contributions.
++
++   6. Trademarks. This License does not grant permission to use the trade
++      names, trademarks, service marks, or product names of the Licensor,
++      except as required for reasonable and customary use in describing the
++      origin of the Work and reproducing the content of the NOTICE file.
++
++   7. Disclaimer of Warranty. Unless required by applicable law or
++      agreed to in writing, Licensor provides the Work (and each
++      Contributor provides its Contributions) on an "AS IS" BASIS,
++      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
++      implied, including, without limitation, any warranties or conditions
++      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
++      PARTICULAR PURPOSE. You are solely responsible for determining the
++      appropriateness of using or redistributing the Work and assume any
++      risks associated with Your exercise of permissions under this License.
++
++   8. Limitation of Liability. In no event and under no legal theory,
++      whether in tort (including negligence), contract, or otherwise,
++      unless required by applicable law (such as deliberate and grossly
++      negligent acts) or agreed to in writing, shall any Contributor be
++      liable to You for damages, including any direct, indirect, special,
++      incidental, or consequential damages of any character arising as a
++      result of this License or out of the use or inability to use the
++      Work (including but not limited to damages for loss of goodwill,
++      work stoppage, computer failure or malfunction, or any and all
++      other commercial damages or losses), even if such Contributor
++      has been advised of the possibility of such damages.
++
++   9. Accepting Warranty or Additional Liability. While redistributing
++      the Work or Derivative Works thereof, You may choose to offer,
++      and charge a fee for, acceptance of support, warranty, indemnity,
++      or other liability obligations and/or rights consistent with this
++      License. However, in accepting such obligations, You may act only
++      on Your own behalf and on Your sole responsibility, not on behalf
++      of any other Contributor, and only if You agree to indemnify,
++      defend, and hold each Contributor harmless for any liability
++      incurred by, or claims asserted against, such Contributor by reason
++      of your accepting any such warranty or additional liability.
++
++   END OF TERMS AND CONDITIONS
++
++   APPENDIX: How to apply the Apache License to your work.
++
++      To apply the Apache License to your work, attach the following
++      boilerplate notice, with the fields enclosed by brackets "{}"
++      replaced with your own identifying information. (Don't include
++      the brackets!)  The text should be enclosed in the appropriate
++      comment syntax for the file format. We also recommend that a
++      file or class name and description of purpose be included on the
++      same "printed page" as the copyright notice for easier
++      identification within third-party archives.
++
++   Copyright {yyyy} {name of copyright owner}
++
++   Licensed under the Apache License, Version 2.0 (the "License");
++   you may not use this file except in compliance with the License.
++   You may obtain a copy of the License at
++
++       http://www.apache.org/licenses/LICENSE-2.0
++
++   Unless required by applicable law or agreed to in writing, software
++   distributed under the License is distributed on an "AS IS" BASIS,
++   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++   See the License for the specific language governing permissions and
++   limitations under the License.
index 0000000,0000000..d4127b8
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,111 @@@
++# CAN Configuration Generator\r
++\r
++## Abstract\r
++\r
++This tool is used to generate a configuration source file for the [Low Level CAN bus binding](https://github.com/iotbzh/CAN_signaling).\r
++This binding needs a configuration provided as a C++ source file.\r
++As long this binding is based on [OpenXC vi-firmware](https://github.com/openxc/vi-firmware), this generator use the JSON format from the [python generator](https://github.com/openxc/openxc-python).\r
++The reference documentation of the JSON file can be found [here](https://github.com/openxc/vi-firmware/blob/master/docs/config/reference.rst).\r
++\r
++## Getting started\r
++\r
++### Build requirements\r
++\r
++* CMake version 3.0 or later\r
++* G++, Clang++ or any C++11 complient compiler.\r
++\r
++* Make sure you already set up the AGL SDK using the following [SDK Quick Setup Guide](http://docs.iot.bzh/docs/getting_started/en/dev/reference/setup-sdk-environment.html). Alternatively, please refer to official guides available on [AGL Developer Site](http://docs.automotivelinux.org/docs/devguides/en/dev/#guides).\r
++\r
++> **CAUTION** Don't source the environment file to get this project compile. We just use CMake from SDK environment, so make sure to not have CMake on the system or remove it if needed with ```sudo apt-get remove cmake```. \r
++\r
++## Compile\r
++\r
++```bash\r
++$ export PATH=$PATH:/xdt/sdk/sysroots/x86_64-aglsdk-linux/usr/bin\r
++$ export WD=$(pwd)\r
++$ git clone https://github.com/iotbzh/can-config-generator.git\r
++$ cd can-config-generator\r
++$ mkdir -p build\r
++$ cd build\r
++$ cmake -G "Unix Makefiles" ..\r
++$ make\r
++```\r
++\r
++### Naming convention\r
++\r
++We chose a doted naming convention because it's a well know schema.\r
++\r
++It separates and organize names into hierarchy. From the left to right, you describe your names using the more common ancestor at the left then more you go to the right the more it will be accurate.\r
++\r
++Let's take an example, here is an example about standard PID name following this convention:\r
++\r
++```\r
++engine.load\r
++engine.coolant.temperature\r
++fuel.pressure\r
++intake.manifold.pressure\r
++engine.speed\r
++vehicle.speed\r
++intake.air.temperature\r
++mass.airflow\r
++throttle.position\r
++running.time\r
++EGR.error\r
++fuel.level\r
++barometric.pressure\r
++commanded.throttle.position\r
++ethanol.fuel.percentage\r
++accelerator.pedal.position\r
++hybrid.battery-pack.remaining.life\r
++engine.oil.temperature\r
++engine.torque\r
++```\r
++\r
++> **NOTE** It's recommended that you follow this naming convention to name your CAN signals.\r
++>\r
++> There is only character `*` that is forbidden in names because it's used as wildcard for subscription and unsubscrition.\r
++>\r
++> This described in the below chapter.\r
++\r
++### Available decoder\r
++\r
++You can use some basic decoder provided by default by the binding which are:\r
++\r
++* decoder_t::noopDecoder : Default decoder if not specified, return raw value from signal's bitfield.\r
++* decoder_t::booleanDecoder : Coerces a numerical value to a boolean.\r
++* decoder_t::stateDecoder : Find and return the corresponding string state for a CAN signal's raw integer value.\r
++\r
++## Generate your config file\r
++\r
++To generate your config file you just have to run the generator using the `-m` option to specify your JSON file.\r
++\r
++```bash\r
++./can-config-generator -m ../tests/basic.json -o configuration-generated.cpp\r
++```\r
++\r
++If you omit the `-o` option, then code is generated on the stdout.\r
++You also can specify a header and a footer file.\r
++These files must be valid C++ fragment as long as they will be inserted as is.\r
++Use the `-h` option to display help.\r
++\r
++## Supported OpenXC items\r
++\r
++As long as the low level CAN signaling binding doesn't fully support OpenXC yet, this generator is also limited.\r
++For instance, `initializers`, `loopers`, `commands` and `handlers` nodes are ignored for now.\r
++This generator will follow OpenXC support status of the low level CAN signaling binding.\r
++\r
++The `buses` item will not be supported by this generator because the binding use another way to declare and configure buses. Please refer to the binding's documentation.\r
++\r
++## Known issues\r
++\r
++* Each `diagnostic_message` must define the same `bus` as the binding will use only one bus.\r
++\r
++## Dependencies\r
++\r
++* [json](https://github.com/nlohmann/json) by nlohmann\r
++\r
++## License\r
++\r
++Copyright 2017 - iotbzh\r
++\r
++Licensed under the [Apache License 2.0](https://github.com/iotbzh/can-config-generator/blob/master/LICENSE)\r
index 0000000,0000000..b6d9216
new file mode 100755 (executable)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,81 @@@
++#!/bin/bash
++
++function build {
++      echo "ACTION: build"
++      if [ ! -d "$1/$2" ]; then
++              echo "INFO: build dir ($1/$2) doesn't exist, created it!"
++              mkdir -p "$1/$2"
++      fi
++      pushd "$1/$2"
++      #cd "$1/$2"
++      cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$3 $1
++      make
++      popd
++}
++
++function clean {
++      echo "ACTION: clean"
++      if [ -d "$1/$2" ]; then
++              rm -vrf "$1/$2"
++      fi
++}
++
++function rebuild {
++      clean $1 $2
++      build $1 $2 $3
++}
++
++function printhelp {
++      echo "Usage: build.sh <action> <subdir> [config]"
++      echo "  action: can be one of the following"
++      echo "          build: build this project."
++      echo "          rebuild: rebuild this project."
++      echo "          clean: clean the previous build."
++      echo "          install: install the build result."
++      echo "  subdir: the subdir into which the build is done."
++      echo "  config: can be Debug or Release. Ignored if the action is 'clean'."
++}
++
++function checkparams {
++      if [ "$#" -ne "$(($1+1))" ]; then
++              echo "ERROR: Wrong number of parameters, expected $1 but got $(($#-1))"
++              printhelp
++              exit 1
++      fi
++}
++
++function main {
++      CURRENT_DIR=$( dirname "$(readlink -f "$0")" )
++      echo "Current script: $CURRENT_DIR"
++
++      if [ "$#" -lt "1" ]; then
++              echo "ERROR: At least <action> must be specified!"
++              exit 1
++      fi
++
++      case "$1" in
++              "build")
++                      checkparams 3 $*
++                      build $CURRENT_DIR $2 $3
++                      ;;
++              "rebuild")
++                      checkparams 3 $*
++                      rebuild $CURRENT_DIR $2 $3
++                      ;;
++              "clean")
++                      checkparams 2 $*
++                      clean $CURRENT_DIR $2
++                      ;;
++              "install")
++                      checkparams 3 $*
++                      echo "ERROR: Not implemented yet!"
++                      ;;
++              *)
++                      echo "ERROR: Unknown action '$3'!"
++                      exit 1 
++                      ;;
++      esac
++}
++
++main $*
++
index 0000000,cfefed8..cfefed8
mode 000000,100644..100644
--- /dev/null
index 0000000,cf08e1a..cf08e1a
mode 000000,100644..100644
--- /dev/null
index 0000000,0a968a9..0a968a9
mode 000000,100755..100755
--- /dev/null
index 0000000,74e1273..74e1273
mode 000000,100755..100755
--- /dev/null
index 0000000,4cc0682..4cc0682
mode 000000,100755..100755
--- /dev/null
index 0000000,2c05226..2c05226
mode 000000,100755..100755
--- /dev/null
index 0000000,74d5c94..74d5c94
mode 000000,100755..100755
--- /dev/null
index 0000000,30895cb..30895cb
mode 000000,100755..100755
--- /dev/null
index 0000000,6c3ff82..6c3ff82
mode 000000,100755..100755
--- /dev/null
index 0000000,64dba75..64dba75
mode 000000,100755..100755
--- /dev/null
index 0000000,32cd1b4..32cd1b4
mode 000000,100755..100755
--- /dev/null
index 0000000,e8bb5c9..e8bb5c9
mode 000000,100644..100644
--- /dev/null
index 0000000,4316f15..4316f15
mode 000000,100644..100644
--- /dev/null
index 0000000,648427a..648427a
mode 000000,100755..100755
--- /dev/null