Skip to content

New monitor impl #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/RELEASES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
)
3 changes: 2 additions & 1 deletion src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
54 changes: 38 additions & 16 deletions src/codegen/c-main-generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <canmonitorutil.h>\n"
"\n"
);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion src/codegen/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#include <stdint.h>

#define CODEGEN_LIB_VERSION_MAJ (2)
#define CODEGEN_LIB_VERSION_MIN (4)
#define CODEGEN_LIB_VERSION_MIN (5)
16 changes: 16 additions & 0 deletions test/gencode/conf/dbccodeconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

16 changes: 3 additions & 13 deletions test/gencode/inc/canmonitorutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions test/gencode/lib/testdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions test/gencode/lib/testdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <canmonitorutil.h>

#endif // TESTDB_USE_DIAG_MONITORS
Expand Down
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