From 9e444ade872bc436cf12bc12d03c3a5d51ac0b9e Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 11 Apr 2017 12:55:23 +0200 Subject: [PATCH] Handle project new architecture using new CMakeFile Change-Id: I672a9b49d9d5a3953ba6dccaafbbd738839f64a6 Signed-off-by: Romain Forlot # Conflicts: # low-can-binding/libs/bitfield-c # low-can-binding/libs/isotp-c # low-can-binding/libs/openxc-message-format --- .gitmodules | 24 +- CMakeLists.txt | 177 ++++++++++- etc/config.cmake | 75 +++++ {src => etc}/export.map | 0 low-can-binding/CMakeLists.txt | 81 +++++ {src => low-can-binding}/can/can-bus-dev.cpp | 0 {src => low-can-binding}/can/can-bus-dev.hpp | 0 {src => low-can-binding}/can/can-bus.cpp | 0 {src => low-can-binding}/can/can-bus.hpp | 0 {src => low-can-binding}/can/can-command.hpp | 0 {src => low-can-binding}/can/can-decoder.cpp | 0 {src => low-can-binding}/can/can-decoder.hpp | 0 .../can/can-message-definition.cpp | 0 .../can/can-message-definition.hpp | 0 {src => low-can-binding}/can/can-message-set.cpp | 0 {src => low-can-binding}/can/can-message-set.hpp | 0 {src => low-can-binding}/can/can-message.cpp | 0 {src => low-can-binding}/can/can-message.hpp | 0 {src => low-can-binding}/can/can-signals.cpp | 0 {src => low-can-binding}/can/can-signals.hpp | 0 low-can-binding/configuration-generated.cpp | 350 +++++++++++++++++++++ {src => low-can-binding}/configuration.cpp | 0 {src => low-can-binding}/configuration.hpp | 0 .../diagnostic/active-diagnostic-request.cpp | 0 .../diagnostic/active-diagnostic-request.hpp | 0 .../diagnostic/diagnostic-manager.cpp | 0 .../diagnostic/diagnostic-manager.hpp | 0 .../diagnostic/diagnostic-message.cpp | 0 .../diagnostic/diagnostic-message.hpp | 0 {src => low-can-binding}/libs/bitfield-c | 0 {src => low-can-binding}/libs/isotp-c | 0 low-can-binding/libs/nanopb | 1 + .../libs/openxc-message-format | 0 low-can-binding/libs/uds-c | 1 + {src => low-can-binding}/low-can-binding.cpp | 0 {src => low-can-binding}/low-can-binding.hpp | 0 .../packaging/wgt/config.xml | 0 .../packaging/wgt/etc/can_buses.json | 0 {src => low-can-binding/packaging/wgt}/icon.png | Bin .../subCMakeLists.txt | 22 +- {src => low-can-binding}/utils/config-parser.cpp | 0 {src => low-can-binding}/utils/config-parser.hpp | 0 {src => low-can-binding}/utils/openxc-utils.cpp | 0 {src => low-can-binding}/utils/openxc-utils.hpp | 0 {src => low-can-binding}/utils/signals.cpp | 0 {src => low-can-binding}/utils/signals.hpp | 0 {src => low-can-binding}/utils/socket.cpp | 0 {src => low-can-binding}/utils/socket.hpp | 0 {src => low-can-binding}/utils/timer.cpp | 0 {src => low-can-binding}/utils/timer.hpp | 0 src/libs/nanopb | 1 - src/libs/uds-c | 1 - 52 files changed, 708 insertions(+), 25 deletions(-) create mode 100644 etc/config.cmake rename {src => etc}/export.map (100%) create mode 100644 low-can-binding/CMakeLists.txt rename {src => low-can-binding}/can/can-bus-dev.cpp (100%) rename {src => low-can-binding}/can/can-bus-dev.hpp (100%) rename {src => low-can-binding}/can/can-bus.cpp (100%) rename {src => low-can-binding}/can/can-bus.hpp (100%) rename {src => low-can-binding}/can/can-command.hpp (100%) rename {src => low-can-binding}/can/can-decoder.cpp (100%) rename {src => low-can-binding}/can/can-decoder.hpp (100%) rename {src => low-can-binding}/can/can-message-definition.cpp (100%) rename {src => low-can-binding}/can/can-message-definition.hpp (100%) rename {src => low-can-binding}/can/can-message-set.cpp (100%) rename {src => low-can-binding}/can/can-message-set.hpp (100%) rename {src => low-can-binding}/can/can-message.cpp (100%) rename {src => low-can-binding}/can/can-message.hpp (100%) rename {src => low-can-binding}/can/can-signals.cpp (100%) rename {src => low-can-binding}/can/can-signals.hpp (100%) create mode 100644 low-can-binding/configuration-generated.cpp rename {src => low-can-binding}/configuration.cpp (100%) rename {src => low-can-binding}/configuration.hpp (100%) rename {src => low-can-binding}/diagnostic/active-diagnostic-request.cpp (100%) rename {src => low-can-binding}/diagnostic/active-diagnostic-request.hpp (100%) rename {src => low-can-binding}/diagnostic/diagnostic-manager.cpp (100%) rename {src => low-can-binding}/diagnostic/diagnostic-manager.hpp (100%) rename {src => low-can-binding}/diagnostic/diagnostic-message.cpp (100%) rename {src => low-can-binding}/diagnostic/diagnostic-message.hpp (100%) rename {src => low-can-binding}/libs/bitfield-c (100%) rename {src => low-can-binding}/libs/isotp-c (100%) create mode 160000 low-can-binding/libs/nanopb rename {src => low-can-binding}/libs/openxc-message-format (100%) create mode 160000 low-can-binding/libs/uds-c rename {src => low-can-binding}/low-can-binding.cpp (100%) rename {src => low-can-binding}/low-can-binding.hpp (100%) rename src/config.xml.in => low-can-binding/packaging/wgt/config.xml (100%) rename src/can_buses.json.in => low-can-binding/packaging/wgt/etc/can_buses.json (100%) rename {src => low-can-binding/packaging/wgt}/icon.png (100%) rename src/CMakeLists.txt => low-can-binding/subCMakeLists.txt (81%) rename {src => low-can-binding}/utils/config-parser.cpp (100%) rename {src => low-can-binding}/utils/config-parser.hpp (100%) rename {src => low-can-binding}/utils/openxc-utils.cpp (100%) rename {src => low-can-binding}/utils/openxc-utils.hpp (100%) rename {src => low-can-binding}/utils/signals.cpp (100%) rename {src => low-can-binding}/utils/signals.hpp (100%) rename {src => low-can-binding}/utils/socket.cpp (100%) rename {src => low-can-binding}/utils/socket.hpp (100%) rename {src => low-can-binding}/utils/timer.cpp (100%) rename {src => low-can-binding}/utils/timer.hpp (100%) delete mode 160000 src/libs/nanopb delete mode 160000 src/libs/uds-c diff --git a/.gitmodules b/.gitmodules index de99e87..74a13e8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,15 @@ -[submodule "src/libs/openxc-message-format"] - path = src/libs/openxc-message-format - url = https://github.com/openxc/openxc-message-format.git -[submodule "src/libs/nanopb"] - path = src/libs/nanopb +[submodule "low-can-binding/libs/openxc-message-format"] + path = low-can-binding/libs/openxc-message-format + url = https://github.com/openxc/openxc-message-format +[submodule "low-can-binding/libs/nanopb"] + path = low-can-binding/libs/nanopb url = https://github.com/nanopb/nanopb.git -[submodule "src/libs/uds-c"] - path = src/libs/uds-c +[submodule "low-can-binding/libs/uds-c"] + path = low-can-binding/libs/uds-c url = https://github.com/openxc/uds-c.git -[submodule "src/libs/bitfield-c"] - path = src/libs/bitfield-c +[submodule "low-can-binding/libs/bitfield-c"] + path = low-can-binding/libs/bitfield-c url = https://github.com/openxc/bitfield-c.git -[submodule "src/libs/isotp-c"] - path = src/libs/isotp-c - url = https://github.com/openxc/isotp-c.git +[submodule "low-can-binding/libs/isotp-c"] + path = low-can-binding/libs/isotp-c + url = https://github.com/openxc/isotp-c diff --git a/CMakeLists.txt b/CMakeLists.txt index 233ee69..4ba6136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,7 @@ ########################################################################### -# Copyright 2016 IoT.bzh +# Copyright 2015, 2016, 2017 IoT.bzh # -# author: José Bollo -# author: Stéphane Desneux +# author: Fulup Ar Foll # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +16,172 @@ # limitations under the License. ########################################################################### -cmake_minimum_required(VERSION 3.3) -project(low-can-binding) -add_subdirectory(src) + +#-------------------------------------------------------------------------- +# WARNING: +# Do not change this cmake template +# Customise your preferences in "./etc/config.cmake" +#-------------------------------------------------------------------------- + + +# Generic useful macro +# ----------------------- +macro(PROJECT_TARGET_ADD TARGET_NAME) + set(PROJECT_TARGETS ${PROJECT_TARGETS} ${TARGET_NAME} CACHE INTERNAL PROJECT_TARGETS) +endmacro(PROJECT_TARGET_ADD) + +macro(defstr name value) + add_definitions(-D${name}=${value}) +endmacro(defstr) + +macro(setc name value) + if(NOT DEFINED ${name}) + set(${name} ${value}) + endif(NOT DEFINED ${name}) +endmacro(setc) + +macro(fill_include_dir path) + file(GLOB_RECURSE dirlist LIST_DIRECTORIES true "${path}/*") + foreach(filename ${dirlist}) + if(IS_DIRECTORY ${filename}) + include_directories(${filename}) + endif(IS_DIRECTORY ${filename}) + endforeach() +endmacro(fill_include_dir) + +function(find_source_files path) + file(GLOB_RECURSE filelist "${path}/*.[cpx]") + foreach(filename ${filelist}) + if(NOT ${filename} MATCHES ".*(test|example|sample).*") + string(APPEND sources "${filename};") + endif(NOT ${filename} MATCHES ".*(test|example|sample).*") + endforeach() + set(sources_files ${sources} PARENT_SCOPE) +endfunction(find_source_files) + +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) +setc(CMAKE_BUILD_TYPE Debug) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMP0048 1) + +# Compiler selection should append before project definition +# ----------------------------------------------------------- +foreach (GCC_VERSION "6" "5") + execute_process(COMMAND gcc-${GCC_VERSION} -dumpversion RESULT_VARIABLE GCCRC OUTPUT_QUIET ERROR_QUIET) + if(GCCRC EQUAL 0) + set(CMAKE_C_COMPILER "gcc-${GCC_VERSION}") + set(CMAKE_CXX_COMPILER "g++-${GCC_VERSION}") + set(CMAKE_C_VERSION ${GCC_VERSION}) + break() + endif(GCCRC EQUAL 0) +endforeach(GCC_VERSION) + +# Include project configuration +# ------------------------------ +include(${CMAKE_CURRENT_SOURCE_DIR}/etc/config.cmake) +project(${NAME} VERSION ${VERSION}) +setc(PROJECT_PRETTY_NAME "${PRETTY_NAME}") +setc(PROJECT_DESCRIPTION "${DESCRIPTION}") +setc(PROJECT_WGT_DIR "packaging/wgt") +setc(PROJECT_LIBDIR "libs") +setc(PROJECT_RESOURCES "data") + +message(STATUS "") +message(STATUS "Project=${PROJECT_NAME}/${VERSION}[${PRETTY_NAME} ${DESCRIPTION}]") +message(STATUS "") +message(STATUS "gcc/g++ version-${CMAKE_C_VERSION}.x selected") + +INCLUDE(FindPkgConfig) +INCLUDE(CheckIncludeFiles) +INCLUDE(CheckLibraryExists) +INCLUDE(GNUInstallDirs) + +# Default compilation options +############################################################################ +link_libraries(-Wl,--as-needed -Wl,--gc-sections) +add_compile_options(-Wall -Wextra -Wconversion) +add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care? +add_compile_options(-Wno-sign-compare -Wno-sign-conversion) +add_compile_options(-Werror=maybe-uninitialized) +add_compile_options(-Werror=implicit-function-declaration) +add_compile_options(-ffunction-sections -fdata-sections) +add_compile_options(-fPIC) +add_compile_options(-g) + +setc(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE") +setc(CMAKE_C_FLAGS_DEBUG "-g -O2 -ggdb -Wp,-U_FORTIFY_SOURCE") +setc(CMAKE_C_FLAGS_RELEASE "-O2") +setc(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage") +setc(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/Install") + +# (BUG!!!) as PKG_CONFIG_PATH does not work [should be en env variable] +setc(PKG_CONFIG_USE_CMAKE_PREFIX_PATH 1) + +# Loop on required package and add options +foreach (PKG_CONFIG ${PKG_REQUIRED_LIST}) + PKG_CHECK_MODULES(${PKG_CONFIG} REQUIRED ${PKG_CONFIG}) + + INCLUDE_DIRECTORIES(${${PKG_CONFIG}_INCLUDE_DIRS}) + list (APPEND link_libraries ${${PKG_CONFIG}_LIBRARIES}) + add_compile_options (${${PKG_CONFIG}_CFLAGS}) +endforeach(PKG_CONFIG) + +# Optional LibEfence Malloc debug library +IF(CMAKE_BUILD_TYPE MATCHES DEBUG) +CHECK_LIBRARY_EXISTS(efence malloc "" HAVE_LIBEFENCE) +IF(HAVE_LIBEFENCE) + MESSAGE(STATUS "Linking with ElectricFence for debugging purposes...") + SET(libefence_LIBRARIES "-lefence") + list (APPEND link_libraries libefence_LIBRARIES}) +ENDIF(HAVE_LIBEFENCE) +ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG) + +# set default include directories +INCLUDE_DIRECTORIES(${EXTRA_INCLUDE_DIRS}) + +# If no install dir try to guest some smart default +if(BINDINGS_INSTALL_PREFIX) + set(BINDINGS_INSTALL_DIR ${BINDINGS_INSTALL_PREFIX}/${PROJECT_NAME}) +else() + set(BINDINGS_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}) +endif() + +# Default Linkflag +if(NOT BINDINGS_LINK_FLAG) + set(BINDINGS_LINK_FLAG "-Wl,--version-script=${CMAKE_SOURCE_DIR}/etc/export.map") +endif() + +# Bindings to compile +# -------------------- +file(GLOB filelist "[A-z]*") +foreach(filename ${filelist}) +if(EXISTS "${filename}/CMakeLists.txt") + add_subdirectory(${filename}) +endif(EXISTS "${filename}/CMakeLists.txt") +endforeach() + +# Add a dummy target to enable global dependency order +# ----------------------------------------------------- +if(EXTRA_DEPENDENCIES_ORDER) + set(DEPENDENCIES_TARGET ${PROJECT_NAME}_extra_dependencies) + add_custom_target(${DEPENDENCIES_TARGET} ALL + DEPENDS ${EXTRA_DEPENDENCY_ORDER} + ) +endif() + +# Cmake does not maintain targets list before 3.7 +# ------------------------------------------------- +if(${CMAKE_VERSION} VERSION_LESS 3.7) + set(GLOBAL_TARGET_LIST ${PROJECT_TARGETS}) +else() + get_property(GLOBAL_TARGET_LIST GLOBAL PROPERTY GlobalTargetList) +endif() + +# Print developer helper message when everything is done +# ------------------------------------------------------- +if(CLOSING_MESSAGE AND GLOBAL_TARGET_LIST) + add_custom_target(${PROJECT_NAME}_done ALL + DEPENDS ${DEPENDENCIES_TARGET} ${GLOBAL_TARGET_LIST} + COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "++ ${CLOSING_MESSAGE}" + ) +endif() diff --git a/etc/config.cmake b/etc/config.cmake new file mode 100644 index 0000000..dc695b4 --- /dev/null +++ b/etc/config.cmake @@ -0,0 +1,75 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll +# +# 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. +########################################################################### + +# Project Info +# ------------------ +set(NAME low-can-binding) +set(VERSION "1.0") +set(PRETTY_NAME "Low level CAN binding") +set(DESCRIPTION "Expose CAN Low Level APIs through AGL Framework") +set(URL "https://github.com/iotbzh/CAN_signaling") +set(PROJECT_ICON "icon.png") + +# Compilation Mode (DEBUG, RELEASE) +# ---------------------------------- +setc(CMAKE_BUILD_TYPE "DEBUG") + +# PKG_CONFIG required packages +# ----------------------------- +set (PKG_REQUIRED_LIST + json-c + libsystemd + afb-daemon +) + +# Static constante definition +# ----------------------------- +add_compile_options(-D_REENTRANT) +add_compile_options(-DPB_FIELD_16BIT) + +# Print a helper message when every thing is finished +setc(CLOSING_MESSAGE "Test with: afb-daemon --ldpaths=\$\$(pwd)/package/lib --port=1234 --roothttp=\$\$(pwd)/package/htdocs --tracereq=common --token=\"\" --verbose") +# ---------------------------------------------------- + +# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable] +# --------------------------------------------------------------------- +setc(CMAKE_INSTALL_PREFIX ${HOME}/opt) +setc(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +setc(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) + +# Optional dependencies order +# --------------------------- +#set(EXTRA_DEPENDENCIES_ORDER target1 target2 ...) + +# Optional Extra global include path +# ----------------------------------- +#set(EXTRA_INCLUDE_DIRS incdir1 incdir2 ...) + +# Optional extra libraries +# ------------------------- +set(EXTRA_LINK_LIBRARIES nanopb bitfield-c isotp-c uds-c openxc-message-format) + +# Optional force binding installation +# ------------------------------------ +# set(BINDINGS_INSTALL_PREFIX DestinationPath ) + +# Optional force binding Linking flag +# ------------------------------------ +# set(BINDINGS_LINK_FLAG LinkOptions ) + + diff --git a/src/export.map b/etc/export.map similarity index 100% rename from src/export.map rename to etc/export.map diff --git a/low-can-binding/CMakeLists.txt b/low-can-binding/CMakeLists.txt new file mode 100644 index 0000000..ae035c9 --- /dev/null +++ b/low-can-binding/CMakeLists.txt @@ -0,0 +1,81 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll +# +# 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. +########################################################################### + +# Add target to project dependency list +PROJECT_TARGET_ADD(low-can-binding) + + # Define project Targets + fill_include_dir(${PROJECT_LIBDIR}) + file(GLOB filelist "${PROJECT_LIBDIR}/*") + foreach(filename ${filelist}) + if(IS_DIRECTORY ${filename}) + include_directories(${filename}) + STRING(REGEX REPLACE "^.*\/(.*)$" "\\1" shortname ${filename}) + find_source_files(${PROJECT_LIBDIR}) + add_library(${shortname} STATIC ${sources_files}) + endif(IS_DIRECTORY ${filename}) + endforeach() + + add_library(${PROJECT_NAME} MODULE ${PROJECT_NAME}.cpp configuration.cpp configuration-generated.cpp + can/can-bus.cpp can/can-bus-dev.cpp can/can-message-set.cpp can/can-message-definition.cpp can/can-message.cpp can/can-signals.cpp can/can-decoder.cpp + diagnostic/diagnostic-message.cpp diagnostic/diagnostic-manager.cpp diagnostic/active-diagnostic-request.cpp + utils/signals.cpp utils/openxc-utils.cpp utils/timer.cpp utils/socket.cpp) + + # Binder exposes a unique public entry point + SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES + PREFIX "" + LINK_FLAGS ${BINDINGS_LINK_FLAG} + OUTPUT_NAME ${PROJECT_NAME} + ) + + # Library dependencies (include updates automatically) + TARGET_LINK_LIBRARIES(${PROJECT_NAME} + ${EXTRA_LINK_LIBRARIES} + ${link_libraries} + ) + + # installation directory + INSTALL(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) + + # WGT packaging + message(STATUS "Creation of ${PROJECT_NAME}.wgt package for AppFW") + + configure_file(${PROJECT_WGT_DIR}/config.xml config.xml) + + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_WGT_DIR}/etc") + file(GLOB conf_files "${PROJECT_WGT_DIR}/etc/*") + foreach(filename ${conf_files}) + STRING(REGEX REPLACE "^.*\/(.*)$" "\\1" shortname ${filename}) + message(STATUS "Copying config file ${shortname}") + configure_file(${filename} ${shortname}) + endforeach() + endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_WGT_DIR}/etc") + + add_custom_command( + OUTPUT ${PROJECT_NAME}.wgt + DEPENDS ${PROJECT_NAME} ${EXTRA_LINK_LIBRARIES} ${conf_files} ${PROJECT_WGT_DIR}/config.xml + COMMAND rm -rf package + COMMAND mkdir -p package/lib package/htdocs package/etc + COMMAND cp config.xml package/ + COMMAND cp ${conf_files} package/etc + COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/packaging/wgt/${PROJECT_ICON} package/icon.png + COMMAND cp ${PROJECT_NAME}.so package/lib + COMMAND wgtpkg-pack -f -o ${PROJECT_NAME}.wgt package + ) + add_custom_target(widget ALL DEPENDS ${PROJECT_NAME}.wgt) \ No newline at end of file diff --git a/src/can/can-bus-dev.cpp b/low-can-binding/can/can-bus-dev.cpp similarity index 100% rename from src/can/can-bus-dev.cpp rename to low-can-binding/can/can-bus-dev.cpp diff --git a/src/can/can-bus-dev.hpp b/low-can-binding/can/can-bus-dev.hpp similarity index 100% rename from src/can/can-bus-dev.hpp rename to low-can-binding/can/can-bus-dev.hpp diff --git a/src/can/can-bus.cpp b/low-can-binding/can/can-bus.cpp similarity index 100% rename from src/can/can-bus.cpp rename to low-can-binding/can/can-bus.cpp diff --git a/src/can/can-bus.hpp b/low-can-binding/can/can-bus.hpp similarity index 100% rename from src/can/can-bus.hpp rename to low-can-binding/can/can-bus.hpp diff --git a/src/can/can-command.hpp b/low-can-binding/can/can-command.hpp similarity index 100% rename from src/can/can-command.hpp rename to low-can-binding/can/can-command.hpp diff --git a/src/can/can-decoder.cpp b/low-can-binding/can/can-decoder.cpp similarity index 100% rename from src/can/can-decoder.cpp rename to low-can-binding/can/can-decoder.cpp diff --git a/src/can/can-decoder.hpp b/low-can-binding/can/can-decoder.hpp similarity index 100% rename from src/can/can-decoder.hpp rename to low-can-binding/can/can-decoder.hpp diff --git a/src/can/can-message-definition.cpp b/low-can-binding/can/can-message-definition.cpp similarity index 100% rename from src/can/can-message-definition.cpp rename to low-can-binding/can/can-message-definition.cpp diff --git a/src/can/can-message-definition.hpp b/low-can-binding/can/can-message-definition.hpp similarity index 100% rename from src/can/can-message-definition.hpp rename to low-can-binding/can/can-message-definition.hpp diff --git a/src/can/can-message-set.cpp b/low-can-binding/can/can-message-set.cpp similarity index 100% rename from src/can/can-message-set.cpp rename to low-can-binding/can/can-message-set.cpp diff --git a/src/can/can-message-set.hpp b/low-can-binding/can/can-message-set.hpp similarity index 100% rename from src/can/can-message-set.hpp rename to low-can-binding/can/can-message-set.hpp diff --git a/src/can/can-message.cpp b/low-can-binding/can/can-message.cpp similarity index 100% rename from src/can/can-message.cpp rename to low-can-binding/can/can-message.cpp diff --git a/src/can/can-message.hpp b/low-can-binding/can/can-message.hpp similarity index 100% rename from src/can/can-message.hpp rename to low-can-binding/can/can-message.hpp diff --git a/src/can/can-signals.cpp b/low-can-binding/can/can-signals.cpp similarity index 100% rename from src/can/can-signals.cpp rename to low-can-binding/can/can-signals.cpp diff --git a/src/can/can-signals.hpp b/low-can-binding/can/can-signals.hpp similarity index 100% rename from src/can/can-signals.hpp rename to low-can-binding/can/can-signals.hpp diff --git a/low-can-binding/configuration-generated.cpp b/low-can-binding/configuration-generated.cpp new file mode 100644 index 0000000..2e96570 --- /dev/null +++ b/low-can-binding/configuration-generated.cpp @@ -0,0 +1,350 @@ +#include "configuration.hpp" +#include "can/can-decoder.hpp" + +configuration_t::configuration_t() + : can_message_set_{{0, "example", 0, 1, 5, 0, 20}} + , can_message_definition_ + { + { + can_message_definition_t(0, "can0", 0x620, can_message_format_t::STANDARD, frequency_clock_t(0.00000f), true) + } + } + , can_signals_ + { + { + { + 0, + 0, + "doors.coffer.open", + 88, + 1, + 0.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + }, + { + 0, + 0, + "doors.driver.open", + 78, + 1, + 0.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + }, + { + 0, + 0, + "doors.passenger.open", + 79, + 1, + 0.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + }, + { + 0, + 0, + "doors.rearleft.open", + 86, + 1, + 0.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + }, + { + 0, + 0, + "doors.rearright.open", + 85, + 4, + 0.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + } + } + } + , diagnostic_messages_ + { + { + { + 4, + "engine.load", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 5, + "engine.coolant.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 10, + "fuel.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 11, + "intake.manifold.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 12, + "engine.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 13, + "vehicle.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 15, + "intake.air.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 16, + "mass.airflow", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 17, + "throttle.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 31, + "running.time", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 45, + "EGR.error", + 0, + 0, + UNIT::INVALID, + 0.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 47, + "fuel.level", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 51, + "barometric.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 76, + "commanded.throttle.position", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 82, + "ethanol.fuel.percentage", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 90, + "accelerator.pedal.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 91, + "hybrid.battery-pack.remaining.life", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 92, + "engine.oil.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 94, + "engine.fuel.rate", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + }, + { + 99, + "engine.torque", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + } + } + } +{ +} + +const std::string configuration_t::get_diagnostic_bus() const +{ + return "can0"; +} + + diff --git a/src/configuration.cpp b/low-can-binding/configuration.cpp similarity index 100% rename from src/configuration.cpp rename to low-can-binding/configuration.cpp diff --git a/src/configuration.hpp b/low-can-binding/configuration.hpp similarity index 100% rename from src/configuration.hpp rename to low-can-binding/configuration.hpp diff --git a/src/diagnostic/active-diagnostic-request.cpp b/low-can-binding/diagnostic/active-diagnostic-request.cpp similarity index 100% rename from src/diagnostic/active-diagnostic-request.cpp rename to low-can-binding/diagnostic/active-diagnostic-request.cpp diff --git a/src/diagnostic/active-diagnostic-request.hpp b/low-can-binding/diagnostic/active-diagnostic-request.hpp similarity index 100% rename from src/diagnostic/active-diagnostic-request.hpp rename to low-can-binding/diagnostic/active-diagnostic-request.hpp diff --git a/src/diagnostic/diagnostic-manager.cpp b/low-can-binding/diagnostic/diagnostic-manager.cpp similarity index 100% rename from src/diagnostic/diagnostic-manager.cpp rename to low-can-binding/diagnostic/diagnostic-manager.cpp diff --git a/src/diagnostic/diagnostic-manager.hpp b/low-can-binding/diagnostic/diagnostic-manager.hpp similarity index 100% rename from src/diagnostic/diagnostic-manager.hpp rename to low-can-binding/diagnostic/diagnostic-manager.hpp diff --git a/src/diagnostic/diagnostic-message.cpp b/low-can-binding/diagnostic/diagnostic-message.cpp similarity index 100% rename from src/diagnostic/diagnostic-message.cpp rename to low-can-binding/diagnostic/diagnostic-message.cpp diff --git a/src/diagnostic/diagnostic-message.hpp b/low-can-binding/diagnostic/diagnostic-message.hpp similarity index 100% rename from src/diagnostic/diagnostic-message.hpp rename to low-can-binding/diagnostic/diagnostic-message.hpp diff --git a/src/libs/bitfield-c b/low-can-binding/libs/bitfield-c similarity index 100% rename from src/libs/bitfield-c rename to low-can-binding/libs/bitfield-c diff --git a/src/libs/isotp-c b/low-can-binding/libs/isotp-c similarity index 100% rename from src/libs/isotp-c rename to low-can-binding/libs/isotp-c diff --git a/low-can-binding/libs/nanopb b/low-can-binding/libs/nanopb new file mode 160000 index 0000000..651bdc4 --- /dev/null +++ b/low-can-binding/libs/nanopb @@ -0,0 +1 @@ +Subproject commit 651bdc45f2180b17c132470ff1a3a515dbffaa78 diff --git a/src/libs/openxc-message-format b/low-can-binding/libs/openxc-message-format similarity index 100% rename from src/libs/openxc-message-format rename to low-can-binding/libs/openxc-message-format diff --git a/low-can-binding/libs/uds-c b/low-can-binding/libs/uds-c new file mode 160000 index 0000000..ca20db3 --- /dev/null +++ b/low-can-binding/libs/uds-c @@ -0,0 +1 @@ +Subproject commit ca20db3dd978871bbb9f01f3c862b510c03d1dc4 diff --git a/src/low-can-binding.cpp b/low-can-binding/low-can-binding.cpp similarity index 100% rename from src/low-can-binding.cpp rename to low-can-binding/low-can-binding.cpp diff --git a/src/low-can-binding.hpp b/low-can-binding/low-can-binding.hpp similarity index 100% rename from src/low-can-binding.hpp rename to low-can-binding/low-can-binding.hpp diff --git a/src/config.xml.in b/low-can-binding/packaging/wgt/config.xml similarity index 100% rename from src/config.xml.in rename to low-can-binding/packaging/wgt/config.xml diff --git a/src/can_buses.json.in b/low-can-binding/packaging/wgt/etc/can_buses.json similarity index 100% rename from src/can_buses.json.in rename to low-can-binding/packaging/wgt/etc/can_buses.json diff --git a/src/icon.png b/low-can-binding/packaging/wgt/icon.png similarity index 100% rename from src/icon.png rename to low-can-binding/packaging/wgt/icon.png diff --git a/src/CMakeLists.txt b/low-can-binding/subCMakeLists.txt similarity index 81% rename from src/CMakeLists.txt rename to low-can-binding/subCMakeLists.txt index 4c4132b..23869ef 100644 --- a/src/CMakeLists.txt +++ b/low-can-binding/subCMakeLists.txt @@ -70,10 +70,22 @@ link_libraries(${EXTRAS_LIBRARIES}) ########################################################################### # the library used by the binding : openxc, bitfield, uds, isotp -add_library(bitfield STATIC ${PROJECT_LIBDIR}/bitfield-c/src/bitfield/8byte.c ${PROJECT_LIBDIR}/bitfield-c/src/bitfield/bitarray.c ${PROJECT_LIBDIR}/bitfield-c/src/bitfield/bitfield.c ${PROJECT_LIBDIR}/bitfield-c/src/canutil/read.c ${PROJECT_LIBDIR}/bitfield-c/src/canutil/write.c) -add_library(isotp STATIC ${PROJECT_LIBDIR}/isotp-c/src/isotp/isotp.c ${PROJECT_LIBDIR}/isotp-c/src/isotp/receive.c ${PROJECT_LIBDIR}/isotp-c/src/isotp/send.c) -add_library(uds STATIC ${PROJECT_LIBDIR}/uds-c/src/uds/extras.c ${PROJECT_LIBDIR}/uds-c/src/uds/uds.c) -add_library(openxc STATIC ${PROJECT_LIBDIR}/openxc-message-format/gen/cpp/openxc.pb.c ${PROJECT_LIBDIR}/nanopb/pb_encode.c ${PROJECT_LIBDIR}/nanopb/pb_decode.c ${PROJECT_LIBDIR}/nanopb/pb_common.c) +# Bindings to compile +# -------------------- +file(GLOB filelist "${PROJECT_LIBDIR}/*") +foreach(filename ${filelist}) + if(IS_DIRECTORY ${filename}) + message(STATUS "${filename}") + file(GLOB_RECURSE c_list "*.[chpx]") + string(REGEX REPLACE "^.*\/(.*)$" "\\1" LIB_NAME ${filename}) + add_library(${LIB_NAME} STATIC ${c_list}) + endif(IS_DIRECTORY ${filename}) +endforeach() + +#add_library(bitfield STATIC ${PROJECT_LIBDIR}/bitfield-c/src/bitfield/8byte.c ${PROJECT_LIBDIR}/bitfield-c/src/bitfield/bitarray.c ${PROJECT_LIBDIR}/bitfield-c/src/bitfield/bitfield.c ${PROJECT_LIBDIR}/bitfield-c/src/canutil/read.c ${PROJECT_LIBDIR}/bitfield-c/src/canutil/write.c) +#add_library(isotp STATIC ${PROJECT_LIBDIR}/isotp-c/src/isotp/isotp.c ${PROJECT_LIBDIR}/isotp-c/src/isotp/receive.c ${PROJECT_LIBDIR}/isotp-c/src/isotp/send.c) +#add_library(uds STATIC ${PROJECT_LIBDIR}/uds-c/src/uds/extras.c ${PROJECT_LIBDIR}/uds-c/src/uds/uds.c) +#add_library(openxc STATIC ${PROJECT_LIBDIR}/openxc-message-format/gen/cpp/openxc.pb.c ${PROJECT_LIBDIR}/nanopb/pb_encode.c ${PROJECT_LIBDIR}/nanopb/pb_decode.c ${PROJECT_LIBDIR}/nanopb/pb_common.c) ########################################################################### # the binding for afb @@ -83,7 +95,7 @@ add_library(${PROJECT_NAME} MODULE ${PROJECT_NAME}.cpp configuration.cpp configu can/can-bus.cpp can/can-bus-dev.cpp can/can-message-set.cpp can/can-message-definition.cpp can/can-message.cpp can/can-signals.cpp can/can-decoder.cpp diagnostic/diagnostic-message.cpp diagnostic/diagnostic-manager.cpp diagnostic/active-diagnostic-request.cpp utils/signals.cpp utils/openxc-utils.cpp utils/timer.cpp utils/socket.cpp) -target_link_libraries(${PROJECT_NAME} pthread bitfield uds isotp openxc) +target_link_libraries(${PROJECT_NAME} pthread bitfield-c uds-c isotp-c openxc-message-format) set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" diff --git a/src/utils/config-parser.cpp b/low-can-binding/utils/config-parser.cpp similarity index 100% rename from src/utils/config-parser.cpp rename to low-can-binding/utils/config-parser.cpp diff --git a/src/utils/config-parser.hpp b/low-can-binding/utils/config-parser.hpp similarity index 100% rename from src/utils/config-parser.hpp rename to low-can-binding/utils/config-parser.hpp diff --git a/src/utils/openxc-utils.cpp b/low-can-binding/utils/openxc-utils.cpp similarity index 100% rename from src/utils/openxc-utils.cpp rename to low-can-binding/utils/openxc-utils.cpp diff --git a/src/utils/openxc-utils.hpp b/low-can-binding/utils/openxc-utils.hpp similarity index 100% rename from src/utils/openxc-utils.hpp rename to low-can-binding/utils/openxc-utils.hpp diff --git a/src/utils/signals.cpp b/low-can-binding/utils/signals.cpp similarity index 100% rename from src/utils/signals.cpp rename to low-can-binding/utils/signals.cpp diff --git a/src/utils/signals.hpp b/low-can-binding/utils/signals.hpp similarity index 100% rename from src/utils/signals.hpp rename to low-can-binding/utils/signals.hpp diff --git a/src/utils/socket.cpp b/low-can-binding/utils/socket.cpp similarity index 100% rename from src/utils/socket.cpp rename to low-can-binding/utils/socket.cpp diff --git a/src/utils/socket.hpp b/low-can-binding/utils/socket.hpp similarity index 100% rename from src/utils/socket.hpp rename to low-can-binding/utils/socket.hpp diff --git a/src/utils/timer.cpp b/low-can-binding/utils/timer.cpp similarity index 100% rename from src/utils/timer.cpp rename to low-can-binding/utils/timer.cpp diff --git a/src/utils/timer.hpp b/low-can-binding/utils/timer.hpp similarity index 100% rename from src/utils/timer.hpp rename to low-can-binding/utils/timer.hpp diff --git a/src/libs/nanopb b/src/libs/nanopb deleted file mode 160000 index ffe4aff..0000000 --- a/src/libs/nanopb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ffe4aff87cc3a15863c09aa808adf2381c8f2fb7 diff --git a/src/libs/uds-c b/src/libs/uds-c deleted file mode 160000 index e506334..0000000 --- a/src/libs/uds-c +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e506334e270d77b20c0bc259ac6c7d8c9b702b7a -- 2.16.6