diff --git a/docs/RELEASES.md b/docs/RELEASES.md index 51f7a90..fecdaa7 100644 --- a/docs/RELEASES.md +++ b/docs/RELEASES.md @@ -1,5 +1,14 @@ # Changelog +## v2.5 26.07.2022 + +### Changed + +- GetSystemTick and GetFrameHash functions became macroses. It makes coupling lighter +and adds more flexibility to configure driver +- bitext_t and ubitext_t defined by default in dbccodeconf.h file +- App version is printed when generator runs (not only in help print case) + ## v2.4 24.07.2022 ### Added diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a5c47d..76f8ce5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -project(coderdbc-cli LANGUAGES CXX) +project(${project} LANGUAGES C CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 17) @@ -51,3 +51,18 @@ target_link_libraries( include(GoogleTest) gtest_discover_tests(cctest) + + +add_library( + dummy OBJECT + ${CMAKE_CURRENT_SOURCE_DIR}/../test/gencode/usr/testdb-fmon.c + ${CMAKE_CURRENT_SOURCE_DIR}/../test/gencode/lib/testdb.c + ${CMAKE_CURRENT_SOURCE_DIR}/../test/gencode/butl/bms_testdb-binutil.c +) + +target_include_directories( + dummy PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../test/gencode/conf + ${CMAKE_CURRENT_SOURCE_DIR}/../test/gencode/lib + ${CMAKE_CURRENT_SOURCE_DIR}/../test/gencode/inc +) diff --git a/src/app.cpp b/src/app.cpp index a0b5c43..18ab98d 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -16,6 +16,8 @@ void CoderApp::Run() { + std::cout << "coderdbc v" << CODEGEN_LIB_VERSION_MAJ << "." << CODEGEN_LIB_VERSION_MIN << std::endl << std::endl; + if (ParseParams()) { GenerateCode(); @@ -175,7 +177,6 @@ bool CoderApp::ParseParams() void CoderApp::PrintHelp() { - std::cout << "coderdbc v" << CODEGEN_LIB_VERSION_MAJ << "." << CODEGEN_LIB_VERSION_MIN << std::endl << std::endl; std::cout << "project source code:\thttps://github.com/astand/c-coderdbc\t\t" << std::endl; std::cout << "free web application:\thttps://coderdbc.com" << std::endl; std::cout << std::endl; diff --git a/src/codegen/c-main-generator.cpp b/src/codegen/c-main-generator.cpp index 2dc8d3b..5fd44bd 100644 --- a/src/codegen/c-main-generator.cpp +++ b/src/codegen/c-main-generator.cpp @@ -112,8 +112,6 @@ void CiMainGenerator::Gen_MainHeader() fwriter->Append( "// This file must define:\n" "// base monitor struct\n" - "// function signature for HASH calculation: (@GetFrameHash)\n" - "// function signature for getting system tick value: (@GetSystemTick)\n" "#include \n" "\n" ); @@ -316,7 +314,24 @@ void CiMainGenerator::Gen_MainSource() fwriter->Append(); fwriter->Append("#endif // %s", fdesc->gen.usemon_def.c_str()); - fwriter->Append(2); + fwriter->Append(""); + fwriter->Append("// This macro guard for the case when you need to enable"); + fwriter->Append("// using diag monitors but there is no necessity in proper"); + fwriter->Append("// SysTick provider. For providing one you need define macro"); + fwriter->Append("// before this line - in dbccodeconf.h"); + fwriter->Append(""); + fwriter->Append("#ifndef GetSystemTick"); + fwriter->Append("#define GetSystemTick() (0u)"); + fwriter->Append("#endif"); + fwriter->Append(""); + fwriter->Append("// This macro guard is for the case when you want to build"); + fwriter->Append("// app with enabled optoin auto CSM, but don't yet have"); + fwriter->Append("// proper getframehash implementation"); + fwriter->Append(""); + fwriter->Append("#ifndef GetFrameHash"); + fwriter->Append("#define GetFrameHash(a,b,c,d,e) (0u)"); + fwriter->Append("#endif"); + fwriter->Append(); fwriter->Append(extend_func_body, ext_sig_func_name), 1; @@ -412,6 +427,9 @@ void CiMainGenerator::Gen_CanMonUtil() fwriter->Append(" // XOR8 = 0,"); fwriter->Append(" // XOR4 = 1,"); fwriter->Append(" // etc"); + fwriter->Append(""); + fwriter->Append(" // it is up to user to have or to skip final enum value - @CRC_ALG_COUNT"); + fwriter->Append(" CRC_ALG_COUNT"); fwriter->Append("} DbcCanCrcMethods;"); fwriter->Append(""); fwriter->Append("typedef struct"); @@ -444,19 +462,6 @@ void CiMainGenerator::Gen_CanMonUtil() fwriter->Append(""); fwriter->Append("} FrameMonitor_t;"); fwriter->Append(""); - fwriter->Append("/* ----------------------------------------------------------------------------- */"); - fwriter->Append("// @d - buff for hash calculation"); - fwriter->Append("// @len - number of bytes for hash calculation"); - fwriter->Append("// @method - hash algorythm."); - fwriter->Append("// @op - optional value"); - fwriter->Append("uint8_t GetFrameHash(const uint8_t* data_ptr, uint8_t len, uint32_t msgid, DbcCanCrcMethods type, uint32_t option);"); - fwriter->Append(""); - fwriter->Append("/* ----------------------------------------------------------------------------- */"); - fwriter->Append("// this function will be called when unpacking is performing. Value will be saved"); - fwriter->Append("// in @last_cycle variable"); - fwriter->Append("uint32_t GetSystemTick(void);"); - fwriter->Append(""); - fwriter->Append(""); fwriter->Append("#ifdef __cplusplus"); fwriter->Append("}"); fwriter->Append("#endif"); @@ -482,6 +487,23 @@ void CiMainGenerator::Gen_DbcCodeConf() fwriter->Append("// #define __DEF_{your_driver_name}__"); fwriter->Append(""); + fwriter->Append("// defualt @__ext_sig__ help types definition"); + fwriter->Append(""); + fwriter->Append("typedef uint32_t ubitext_t;"); + fwriter->Append("typedef int32_t bitext_t;"); + fwriter->Append(""); + fwriter->Append("// To provide a way to make missing control correctly you"); + fwriter->Append("// have to define macro @GetSystemTick() which has to"); + fwriter->Append("// return kind of tick counter (e.g. 1 ms ticker)"); + fwriter->Append(""); + fwriter->Append("// #define GetSystemTick() __get__tick__()"); + fwriter->Append(""); + fwriter->Append("// To provide a way to calculate hash (crc) for CAN"); + fwriter->Append("// frame's data field you have to define macro @GetFrameHash"); + fwriter->Append(""); + fwriter->Append("// #define GetFrameHash(a,b,c,d,e) __get_hash__(a,b,c,d,e)"); + fwriter->Append(""); + fwriter->Flush(fdesc->file.confdir + '/' + "dbccodeconf.h"); } diff --git a/src/codegen/version.h b/src/codegen/version.h index 8c6c3c9..c028225 100644 --- a/src/codegen/version.h +++ b/src/codegen/version.h @@ -3,4 +3,4 @@ #include #define CODEGEN_LIB_VERSION_MAJ (2) -#define CODEGEN_LIB_VERSION_MIN (4) +#define CODEGEN_LIB_VERSION_MIN (5) diff --git a/test/gencode/conf/dbccodeconf.h b/test/gencode/conf/dbccodeconf.h index 34201b7..9dc616c 100644 --- a/test/gencode/conf/dbccodeconf.h +++ b/test/gencode/conf/dbccodeconf.h @@ -12,3 +12,19 @@ // if you need to allocate rx and tx messages structs put the allocation macro here // #define __DEF_{your_driver_name}__ +// defualt @__ext_sig__ help types definition + +typedef uint32_t ubitext_t; +typedef int32_t bitext_t; + +// To provide a way to make missing control correctly you +// have to define macro @GetSystemTick() which has to +// return kind of tick counter (e.g. 1 ms ticker) + +// #define GetSystemTick() __get__tick__() + +// To provide a way to calculate hash (crc) for CAN +// frame's data field you have to define macro @GetFrameHash + +// #define GetFrameHash(a,b,c,d,e) __get_hash__(a,b,c,d,e) + diff --git a/test/gencode/inc/canmonitorutil.h b/test/gencode/inc/canmonitorutil.h index 48cd48f..b93dd75 100644 --- a/test/gencode/inc/canmonitorutil.h +++ b/test/gencode/inc/canmonitorutil.h @@ -12,6 +12,9 @@ typedef enum // XOR8 = 0, // XOR4 = 1, // etc + + // it is up to user to have or to skip final enum value - @CRC_ALG_COUNT + CRC_ALG_COUNT } DbcCanCrcMethods; typedef struct @@ -44,19 +47,6 @@ typedef struct } FrameMonitor_t; -/* ----------------------------------------------------------------------------- */ -// @d - buff for hash calculation -// @len - number of bytes for hash calculation -// @method - hash algorythm. -// @op - optional value -uint8_t GetFrameHash(const uint8_t* data_ptr, uint8_t len, uint32_t msgid, DbcCanCrcMethods type, uint32_t option); - -/* ----------------------------------------------------------------------------- */ -// this function will be called when unpacking is performing. Value will be saved -// in @last_cycle variable -uint32_t GetSystemTick(void); - - #ifdef __cplusplus } #endif diff --git a/test/gencode/lib/testdb.c b/test/gencode/lib/testdb.c index a49f1ab..4541c55 100644 --- a/test/gencode/lib/testdb.c +++ b/test/gencode/lib/testdb.c @@ -13,6 +13,22 @@ #endif // TESTDB_USE_DIAG_MONITORS +// This macro guard for the case when you need to enable +// using diag monitors but there is no necessity in proper +// SysTick provider. For providing one you need define macro +// before this line - in dbccodeconf.h + +#ifndef GetSystemTick +#define GetSystemTick() (0u) +#endif + +// This macro guard is for the case when you want to build +// app with enabled optoin auto CSM, but don't yet have +// proper getframehash implementation + +#ifndef GetFrameHash +#define GetFrameHash(a,b,c,d,e) (0u) +#endif // This function performs extension of sign for the signals // which have non-aligned to power of 2 bit's width. diff --git a/test/gencode/lib/testdb.h b/test/gencode/lib/testdb.h index 0e4a1b9..add0dd2 100644 --- a/test/gencode/lib/testdb.h +++ b/test/gencode/lib/testdb.h @@ -16,8 +16,6 @@ extern "C" { #ifdef TESTDB_USE_DIAG_MONITORS // This file must define: // base monitor struct -// function signature for HASH calculation: (@GetFrameHash) -// function signature for getting system tick value: (@GetSystemTick) #include #endif // TESTDB_USE_DIAG_MONITORS pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy