diff --git a/.gitignore b/.gitignore index d1f2963..c1d45a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -**/build +**/build* loc-test* diff --git a/docs/RELEASES.md b/docs/RELEASES.md index 72dbe19..3aa26c7 100644 --- a/docs/RELEASES.md +++ b/docs/RELEASES.md @@ -1,5 +1,22 @@ # Changelog +## v2.2 2022-05-07 + +### Fixed +- "C valid name" check for main driver name and value table descriptions +- Fixed some minor printing artefacts (extra whitespaces, extra lines) +- Very strange issue with wrong naming through all bunch of __***-binutil__ drivers (WTF?) + + +### Added +- Values from value tables and it's descpriptions are printed as macroses + ([issue#9](https://github.com/astand/c-coderdbc/issues/9) from [@delipl](https://github.com/delipl)) +- Added more information about __\_\_ext_sig\_\___ function +- Added strong check of matching of the versions of secondary dbc source + files to main dbc source file (drvname.h) +- Sources which are presumed to be located in __include__ directory are in square brakets + +--- ## v2.1 2022-02-19 diff --git a/run-test-gen.bat b/run-test-gen.bat index 0e4d466..0c38fdb 100755 --- a/run-test-gen.bat +++ b/run-test-gen.bat @@ -1,2 +1,2 @@ -start "coder" "build/Release/coderdbc.exe" -dbc test\testdb.dbc -out -out test\gencode -drvname testdb -nodeutils -rw +start "coder" "build-win/Release/coderdbc.exe" -dbc test\testdb.dbc -out -out test\gencode -drvname testdb -nodeutils -rw pause \ No newline at end of file diff --git a/src/codegen/c-main-generator.cpp b/src/codegen/c-main-generator.cpp index 94e68fe..4906044 100644 --- a/src/codegen/c-main-generator.cpp +++ b/src/codegen/c-main-generator.cpp @@ -14,11 +14,15 @@ const char* ext_sig_func_name = "__ext_sig__"; const char* extend_func_body = - "// To compile this function you need to typedef 'bitext_t' and 'ubitext_t'\n" - "// globally in @dbccodeconf.h or locally in 'dbcdrvname'-config.h\n" - "// Type selection may affect common performance. Most useful types are:\n" - "// bitext_t : int64_t and ubitext_t : uint64_t\n" - "static bitext_t %s( ubitext_t val, uint8_t bits )\n" + "// This function performs extension of sign for the signals\n" + "// which have non-aligned to power of 2 bit's width.\n" + "// The types 'bitext_t' and 'ubitext_t' define maximal bit width which\n" + "// can be correctly handled. You need to select type which can contain\n" + "// n+1 bits where n is the largest signed signal width. For example if\n" + "// the most wide signed signal has a width of 31 bits you need to set\n" + "// bitext_t as int32_t and ubitext_t as uint32_t\n" + "// Defined these typedefs in @dbccodeconf.h or locally in 'dbcdrvname'-config.h\n" + "static bitext_t %s(ubitext_t val, uint8_t bits)\n" "{\n" " ubitext_t const m = 1u << (bits - 1);\n" " return (val ^ m) - m;\n" @@ -86,7 +90,7 @@ void CiMainGenerator::Gen_MainHeader() fwriter->AppendLine(StrPrint("#define %s (%uU)", fdesc->verlow_def.c_str(), p_dlist->ver.low), 2); fwriter->AppendLine("// include current dbc-driver compilation config"); - fwriter->AppendLine(StrPrint("#include \"%s-config.h\"", fdesc->drvname.c_str()), 2); + fwriter->AppendLine(StrPrint("#include <%s-config.h>", fdesc->drvname.c_str()), 2); fwriter->AppendLine(StrPrint("#ifdef %s", fdesc->usemon_def.c_str())); @@ -95,7 +99,7 @@ void CiMainGenerator::Gen_MainHeader() "// base monitor struct\n" "// function signature for HASH calculation: (@GetFrameHash)\n" "// function signature for getting system tick value: (@GetSystemTick)\n" - "#include \"canmonitorutil.h\"\n" + "#include \n" "\n" ); @@ -137,6 +141,30 @@ void CiMainGenerator::Gen_MainHeader() { max_sig_name_len = s.Name.size(); } + + // For each signal in current message print value tables definitions + if (s.ValDefs.vpairs.size() > 0) + { + fwriter->AppendLine(StrPrint("\n// Value tables for @%s signal", s.Name.c_str()), 2); + + for (auto i = 0; i < s.ValDefs.vpairs.size(); i++) + { + // The value table definition consists of 'signal name + message name + value definition' + // This provides reliable way of avoiding issues with same macros names + std::string defname = StrPrint("%s_%s_%s", s.Name.c_str(), m.Name.c_str(), s.ValDefs.vpairs[i].first.c_str()); + + // @ifndef guard for the case when different values of table have + // the same name (it is valid for DBC file format) + // For this case only one of same named values will be available as macro + fwriter->AppendLine(StrPrint("#ifndef %s", defname.c_str())); + + fwriter->AppendLine(StrPrint("#define %s_%s_%s (%d)", + s.Name.c_str(), m.Name.c_str(), s.ValDefs.vpairs[i].first.c_str(), + s.ValDefs.vpairs[i].second)); + + fwriter->AppendLine(StrPrint("#endif"), 2); + } + } } fwriter->AppendText("\n"); @@ -238,6 +266,13 @@ void CiMainGenerator::Gen_MainSource() // include main header file fwriter->AppendLine(StrPrint("#include \"%s\"", fdesc->core_h.fname.c_str()), 3); + fwriter->AppendLine("// DBC file version"); + fwriter->AppendLine(StrPrint("#if (%s != (%uU)) || (%s != (%uU))", + fdesc->verhigh_def.c_str(), p_dlist->ver.hi, fdesc->verlow_def.c_str(), p_dlist->ver.low)); + + fwriter->AppendLine(StrPrint("#error The %s dbc source files have different versions", fdesc->DRVNAME.c_str())); + fwriter->AppendLine("#endif", 2); + // put diagmonitor ifdef selection for including @drv-fmon header // with FMon_* signatures to call from unpack function fwriter->AppendLine(StrPrint("#ifdef %s", fdesc->usemon_def.c_str())); @@ -246,7 +281,7 @@ void CiMainGenerator::Gen_MainSource() "// Function prototypes to be called each time CAN frame is unpacked\n" "// FMon function may detect RC, CRC or DLC violation\n"); - fwriter->AppendLine(StrPrint("#include \"%s-fmon.h\"", fdesc->drvname.c_str()), 2); + fwriter->AppendLine(StrPrint("#include <%s-fmon.h>", fdesc->drvname.c_str()), 2); fwriter->AppendLine(StrPrint("#endif // %s", fdesc->usemon_def.c_str()), 3); @@ -307,7 +342,7 @@ void CiMainGenerator::Gen_ConfigHeader() fwriter->AppendLine("#pragma once"); fwriter->AppendLine(""); fwriter->AppendLine("/* include common dbccode configurations */"); - fwriter->AppendLine("#include \"dbccodeconf.h\""); + fwriter->AppendLine("#include "); fwriter->AppendLine(""); fwriter->AppendLine(""); fwriter->AppendLine("/* ------------------------------------------------------------------------- *"); @@ -427,12 +462,12 @@ void CiMainGenerator::Gen_FMonHeader() fwriter->AppendLine(StrPrint("#define %s_FMON (%uU)", fdesc->verhigh_def.c_str(), p_dlist->ver.hi)); fwriter->AppendLine(StrPrint("#define %s_FMON (%uU)", fdesc->verlow_def.c_str(), p_dlist->ver.low), 2); - fwriter->AppendLine(StrPrint("#include \"%s-config.h\"", fdesc->drvname.c_str()), 2); + fwriter->AppendLine(StrPrint("#include <%s-config.h>", fdesc->drvname.c_str()), 2); // put diagmonitor ifdef selection for including @drv-fmon header // with FMon_* signatures to call from unpack function fwriter->AppendLine(StrPrint("#ifdef %s", fdesc->usemon_def.c_str()), 2); - fwriter->AppendLine("#include \"canmonitorutil.h\""); + fwriter->AppendLine("#include "); fwriter->AppendLine("/*\n\ This file contains the prototypes of all the functions that will be called\n\ from each Unpack_*name* function to detect DBC related errors\n\ @@ -461,7 +496,7 @@ void CiMainGenerator::Gen_FMonSource() fwriter->AppendLine("// " + std::regex_replace(fdesc->start_info, std::regex("\n"), "\n// ")); } - fwriter->AppendLine(StrPrint("#include \"%s\"", fdesc->fmon_h.fname.c_str()), 2); + fwriter->AppendLine(StrPrint("#include <%s>", fdesc->fmon_h.fname.c_str()), 2); // put diagmonitor ifdef selection for including @drv-fmon header // with FMon_* signatures to call from unpack function fwriter->AppendLine(StrPrint("#ifdef %s", fdesc->usemon_def.c_str()), 2); @@ -618,16 +653,23 @@ void CiMainGenerator::WriteSigStructField(const SignalDescriptor_t& sig, bool bi fwriter->AppendText(StrPrint(" Bits=%2d", sig.LengthBit)); + size_t offset = 0; + std::string infocmnt{}; + if (sig.IsDoubleSig) { if (sig.Offset != 0) { - fwriter->AppendText(StrPrint(" Offset= %-18f", sig.Offset)); + infocmnt = IndentedString(offset, infocmnt); + offset += 27; + infocmnt += StrPrint(" Offset= %f", sig.Offset); } if (sig.Factor != 1) { - fwriter->AppendText(StrPrint(" Factor= %-15f", sig.Factor)); + infocmnt = IndentedString(offset, infocmnt); + offset += 24; + infocmnt += StrPrint(" Factor= %f", sig.Factor); } } else if (sig.IsSimpleSig == false) @@ -635,20 +677,27 @@ void CiMainGenerator::WriteSigStructField(const SignalDescriptor_t& sig, bool bi // 2 type of signal if (sig.Offset != 0) { - fwriter->AppendText(StrPrint(" Offset= %-18d", (int)sig.Offset)); + infocmnt = IndentedString(offset, infocmnt); + offset += 27; + infocmnt += StrPrint(" Offset= %d", (int)sig.Offset); } if (sig.Factor != 1) { - fwriter->AppendText(StrPrint(" Factor= %-15d", (int)sig.Factor)); + infocmnt = IndentedString(offset, infocmnt); + offset += 24; + infocmnt += StrPrint(" Factor= %d", (int)sig.Factor); } } if (sig.Unit.size() > 0) { - fwriter->AppendText(StrPrint(" Unit:'%s'", sig.Unit.c_str())); + infocmnt = IndentedString(offset, infocmnt); + infocmnt += StrPrint(" Unit:'%s'", sig.Unit.c_str()); } + fwriter->AppendText(infocmnt); + fwriter->AppendLine("", 2); if (!sig.IsSimpleSig) diff --git a/src/codegen/c-util-generator.cpp b/src/codegen/c-util-generator.cpp index 56d9008..0e20bab 100644 --- a/src/codegen/c-util-generator.cpp +++ b/src/codegen/c-util-generator.cpp @@ -107,16 +107,11 @@ void CiUtilGenerator::PrintHeader() tof->AppendLine(openguard.c_str(), 2); // include common dbc code config header - tof->AppendLine("#include \"dbccodeconf.h\"", 2); + tof->AppendLine("#include ", 2); // include c-main driver header - tof->AppendLine(StrPrint("#include \"%s.h\"", file_drvname.c_str()), 2); + tof->AppendLine(StrPrint("#include <%s.h>", file_drvname.c_str()), 2); - // put version info macros - tof->AppendLine("// This version definition comes from main driver version and"); - tof->AppendLine("// can be compared in user code space for strict compatibility test"); - tof->AppendLine(StrPrint("#define %s (%uU)", fdesc->verhigh_def.c_str(), p_dlist->ver.hi)); - tof->AppendLine(StrPrint("#define %s (%uU)", fdesc->verlow_def.c_str(), p_dlist->ver.low), 2); if (rx.size() == 0) { @@ -191,6 +186,14 @@ void CiUtilGenerator::PrintSource() tof->AppendLine(StrPrint("#include \"%s\"", fdesc->util_h.fname.c_str()), 2); + tof->AppendLine("// DBC file version"); + tof->AppendLine(StrPrint("#if (%s != (%uU)) || (%s != (%uU))", + fdesc->verhigh_def.c_str(), p_dlist->ver.hi, fdesc->verlow_def.c_str(), p_dlist->ver.low)); + + tof->AppendLine(StrPrint("#error The %s binutil source file has inconsistency with core dbc lib!", + fdesc->DRVNAME.c_str())); + tof->AppendLine("#endif", 2); + // optional RX and TX struct allocations if (rx.size() > 0 || tx.size() > 0) { diff --git a/src/codegen/version.h b/src/codegen/version.h index 3f25c17..aea8d00 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 (1) +#define CODEGEN_LIB_VERSION_MIN (2) diff --git a/src/helpers/formatter.cpp b/src/helpers/formatter.cpp index 0fb3df4..eb7d74d 100644 --- a/src/helpers/formatter.cpp +++ b/src/helpers/formatter.cpp @@ -17,6 +17,19 @@ static const std::string __typeprint[8] = "uint64_t" }; +std::string IndentedString(size_t n, const std::string& source, const char c) +{ + if (source.length() >= n) + { + return source; + } + else + { + std::string indent(n - source.length(), c); + return source + indent; + } +} + const char* StrPrint(const char* format, ...) { va_list args; @@ -87,3 +100,46 @@ std::string str_trim(std::string s) return s; } + +template +static inline bool in_range(const char c) +{ + return ((c >= L) && (c <= U)); +} + +static bool is_first_valid(const char c) +{ + return in_range<'a', 'z'>(c) || in_range<'A', 'Z'>(c) || c == '_'; +} + +static bool is_nonfirst_valid(const char c) +{ + return is_first_valid(c) || in_range<'0', '9'>(c); +} + +std::string make_c_name(const std::string& s) +{ + std::string ret{}; + + if (s.length() == 0) + { + return ret; + } + + for (auto i = 0; i < s.length(); i++) + { + if ((ret.length() == 0 && is_first_valid(s[i])) || + (ret.length() > 0 && is_nonfirst_valid(s[i]))) + { + // basic C-identifier rule + ret += s[i]; + } + else if (s[i] == ' ') + { + // special case for whitespaces + ret += '_'; + } + } + + return ret; +} diff --git a/src/helpers/formatter.h b/src/helpers/formatter.h index 5c29c0d..d9f5599 100644 --- a/src/helpers/formatter.h +++ b/src/helpers/formatter.h @@ -5,6 +5,8 @@ #include #include +std::string IndentedString(size_t n, const std::string& source, const char c = ' '); + const char* StrPrint(const char* format, ...); std::string PrintType(uint8_t tid); @@ -14,3 +16,11 @@ std::string str_toupper(std::string s); std::string str_tolower(std::string s); std::string str_trim(std::string s); + +/** + * @brief Makes input string valid C-identifier + * + * @param s source string + * @return std::string + */ +std::string make_c_name(const std::string& s); diff --git a/src/maincli.cpp b/src/maincli.cpp index f2dd653..4d8c5c2 100644 --- a/src/maincli.cpp +++ b/src/maincli.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "parser/dbcscanner.h" #include "codegen/c-main-generator.h" #include "codegen/c-util-generator.h" @@ -117,6 +118,16 @@ int main(int argc, char* argv[]) return 0; } + if (drvname_ok) + { + dbc_driver_name = make_c_name(dbc_driver_name); + + if (dbc_driver_name.length() == 0) + { + drvname_ok = false; + } + } + if (drvname_ok && path_ok && dbc_ok) { @@ -199,13 +210,16 @@ int main(int argc, char* argv[]) { std::string util_name = nodes[node] + "_" + dbc_driver_name; + // set new driver name for current node + fscreator->FS.drvname = str_tolower(util_name); + fscreator->FS.DRVNAME = str_toupper(fscreator->FS.drvname); fscreator->FS.util_c.dir = fscreator->FS.utildir; fscreator->FS.util_h.dir = fscreator->FS.utildir; - fscreator->FS.util_h.fname = util_name + ".h"; + fscreator->FS.util_h.fname = str_tolower(fscreator->FS.drvname + "-binutil.h"); fscreator->FS.util_h.fpath = fscreator->FS.utildir + "/" + fscreator->FS.util_h.fname; - fscreator->FS.util_c.fname = util_name + ".c"; + fscreator->FS.util_c.fname = str_tolower(fscreator->FS.drvname + "-binutil.c"); fscreator->FS.util_c.fpath = fscreator->FS.utildir + "/" + fscreator->FS.util_c.fname; MsgsClassification groups; @@ -287,7 +301,9 @@ void PrintUsage() std::cout << "./dbccoder -dbc /home/user/docs/driveshaft.dbc -out /home/user/docs/gen/ -drvname drivedb -nodeutils -rw" << std::endl; - std::cout << "./dbccoder -dbc /home/user/docs/driveshaft.dbc -out /home/user/docs/gen/ -drvname drivedb -nodeutils" << std::endl; + std::cout << + "./dbccoder -dbc /home/user/docs/driveshaft.dbc -out /home/user/docs/gen/ -drvname drivedb -nodeutils" << std::endl; + std::cout << "./dbccoder -dbc /home/user/docs/driveshaft.dbc -out /home/user/docs/gen/ -drvname drivedb" << std::endl; std::cout << std::endl; } diff --git a/src/parser/dbclineparser.cpp b/src/parser/dbclineparser.cpp index b080752..cb4d163 100644 --- a/src/parser/dbclineparser.cpp +++ b/src/parser/dbclineparser.cpp @@ -1,4 +1,6 @@ #include "dbclineparser.h" +#include +#include #include #include #include @@ -466,6 +468,12 @@ bool DbcLineParser::ParseCommentLine(Comment_t* cm, const std::string& line) cm->Text = items[1]; } + if (cm->Text.size() > 0 && cm->Text.back() == '\n') + { + // remove last '\n' symbol in the string end + cm->Text.pop_back(); + } + ret = true; } @@ -515,7 +523,7 @@ bool DbcLineParser::ParseAttributeLine(AttributeDescriptor_t* attr, const std::s return ret; } -bool DbcLineParser::ParseValTableLine(Comment_t* comm, const std::string& line) +bool DbcLineParser::ParseValTableLine(Comment_t* comm, const std::string& line, ValTable_t& vtab) { bool ret = false; @@ -546,10 +554,17 @@ bool DbcLineParser::ParseValTableLine(Comment_t* comm, const std::string& line) comm->Text = ""; comm->ca_target = CommentTarget::Signal; + // prepare value table container + vtab.SigName = items[2]; + vtab.vpairs.clear(); + for (size_t valpair = 3; valpair < (items.size() - 1); valpair += 2) { comm->Text += " " + items[valpair + 0] + " : "; comm->Text += items[valpair + 1] + '\n'; + + auto valdef = make_c_name(items[valpair + 1]); + vtab.vpairs.push_back({valdef, (uint32_t)atoll((items[valpair + 0]).c_str())}); } if (comm->Text.size() > 0) diff --git a/src/parser/dbclineparser.h b/src/parser/dbclineparser.h index a069c9a..9b0c025 100644 --- a/src/parser/dbclineparser.h +++ b/src/parser/dbclineparser.h @@ -65,8 +65,9 @@ class DbcLineParser { bool ParseCommentLine(Comment_t* cm, const std::string& line); // tries to parse value table string in line - // and load result to attr ValueStr, return true if parsed ok - bool ParseValTableLine(Comment_t* cm, const std::string& line); + // saves result as comment text in @cm object, and as + // pairs of items (definition / value) in @vtab + bool ParseValTableLine(Comment_t* cm, const std::string& line, ValTable_t& vtab); /** * @brief tries to find string with information about frame which has diff --git a/src/parser/dbcscanner.cpp b/src/parser/dbcscanner.cpp index 76b2820..d221a6f 100644 --- a/src/parser/dbcscanner.cpp +++ b/src/parser/dbcscanner.cpp @@ -154,6 +154,8 @@ void DbcScanner::ParseOtherInfo(istream& readstrm) Comment_t cmmnt; + ValTable_t vals; + AttributeDescriptor_t attr; while (!readstrm.eof()) @@ -229,7 +231,7 @@ void DbcScanner::ParseOtherInfo(istream& readstrm) } } - if (lparser.ParseValTableLine(&cmmnt, sline)) + if (lparser.ParseValTableLine(&cmmnt, sline, vals)) { // update message comment field auto msg = find_message(dblist.msgs, cmmnt.MsgId); @@ -250,6 +252,8 @@ void DbcScanner::ParseOtherInfo(istream& readstrm) { // signal has been found, update commnet text msg->Signals[i].ValueText = cmmnt.Text; + // save collected value table's definitions to signal + msg->Signals[i].ValDefs = vals; } } } diff --git a/src/parser/dbcscanner.h b/src/parser/dbcscanner.h index 0aefda1..7abff93 100644 --- a/src/parser/dbcscanner.h +++ b/src/parser/dbcscanner.h @@ -31,4 +31,7 @@ class DbcScanner { DbcLineParser lparser; + // this variable is used for gathering value table signal's information + std::pair vpairs; + }; diff --git a/src/types/comment.h b/src/types/comment.h index 34527b3..ff1e3f2 100644 --- a/src/types/comment.h +++ b/src/types/comment.h @@ -2,6 +2,7 @@ #include #include +#include enum class CommentTarget { @@ -27,3 +28,12 @@ typedef struct std::string Text; } Comment_t; + + +typedef struct +{ + std::string SigName; + + std::vector> vpairs{}; + +} ValTable_t; diff --git a/src/types/message.h b/src/types/message.h index bd33f9c..99b0225 100644 --- a/src/types/message.h +++ b/src/types/message.h @@ -83,6 +83,8 @@ typedef struct std::vector RecS; + ValTable_t ValDefs; + std::string CommentText; std::string ValueText; diff --git a/test/gencode/butl/BCM_testdb.c b/test/gencode/butl/BCM_testdb.c deleted file mode 100644 index a62802f..0000000 --- a/test/gencode/butl/BCM_testdb.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "BCM_testdb.h" - -#ifdef __DEF_TESTDB__ - -testdb_rx_t testdb_rx; - -testdb_tx_t testdb_tx; - -#endif // __DEF_TESTDB__ - -uint32_t testdb_Receive(testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_) -{ - uint32_t recid = 0; - if (_id == 0x360U) { - recid = Unpack_FLT_TEST_1_testdb(&(_m->FLT_TEST_1), _d, dlc_); - } else { - if (_id == 0x777U) { - recid = Unpack_SIG_TEST_1_testdb(&(_m->SIG_TEST_1), _d, dlc_); - } else if (_id == 0x1FFFFFF6U) { - recid = Unpack_EMPTY_EXT_ID_testdb(&(_m->EMPTY_EXT_ID), _d, dlc_); - } - } - - return recid; -} - diff --git a/test/gencode/butl/BCM_testdb.h b/test/gencode/butl/BCM_testdb.h deleted file mode 100644 index ff116e0..0000000 --- a/test/gencode/butl/BCM_testdb.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dbccodeconf.h" - -#include "testdb.h" - -// This version definition comes from main driver version and -// can be compared in user code space for strict compatibility test -#define VER_TESTDB_MAJ (1U) -#define VER_TESTDB_MIN (10U) - -typedef struct -{ - FLT_TEST_1_t FLT_TEST_1; - SIG_TEST_1_t SIG_TEST_1; - EMPTY_EXT_ID_t EMPTY_EXT_ID; -} testdb_rx_t; - -typedef struct -{ - UTEST_2_t UTEST_2; - EMPTY_0_t EMPTY_0; - UTEST_3_t UTEST_3; - EMPTY_EXT_ID_t EMPTY_EXT_ID; -} testdb_tx_t; - -uint32_t testdb_Receive(testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc); - -#ifdef __DEF_TESTDB__ - -extern testdb_rx_t testdb_rx; - -extern testdb_tx_t testdb_tx; - -#endif // __DEF_TESTDB__ - -#ifdef __cplusplus -} -#endif diff --git a/test/gencode/butl/BMS_testdb.h b/test/gencode/butl/BMS_testdb.h deleted file mode 100644 index 26b2c31..0000000 --- a/test/gencode/butl/BMS_testdb.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dbccodeconf.h" - -#include "testdb.h" - -// This version definition comes from main driver version and -// can be compared in user code space for strict compatibility test -#define VER_TESTDB_MAJ (1U) -#define VER_TESTDB_MIN (10U) - -typedef struct -{ - UTEST_2_t UTEST_2; - EMPTY_0_t EMPTY_0; - UTEST_3_t UTEST_3; - EMPTY_EXT_ID_t EMPTY_EXT_ID; -} testdb_rx_t; - -typedef struct -{ - EMPTY_0_t EMPTY_0; - FLT_TEST_1_t FLT_TEST_1; -} testdb_tx_t; - -uint32_t testdb_Receive(testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc); - -#ifdef __DEF_TESTDB__ - -extern testdb_rx_t testdb_rx; - -extern testdb_tx_t testdb_tx; - -#endif // __DEF_TESTDB__ - -#ifdef __cplusplus -} -#endif diff --git a/test/gencode/butl/EPS_testdb.c b/test/gencode/butl/EPS_testdb.c deleted file mode 100644 index 735e2c9..0000000 --- a/test/gencode/butl/EPS_testdb.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "EPS_testdb.h" - -#ifdef __DEF_TESTDB__ - -testdb_tx_t testdb_tx; - -#endif // __DEF_TESTDB__ - diff --git a/test/gencode/butl/EPS_testdb.h b/test/gencode/butl/EPS_testdb.h deleted file mode 100644 index c395ffc..0000000 --- a/test/gencode/butl/EPS_testdb.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dbccodeconf.h" - -#include "testdb.h" - -// This version definition comes from main driver version and -// can be compared in user code space for strict compatibility test -#define VER_TESTDB_MAJ (1U) -#define VER_TESTDB_MIN (10U) - -// There is no any RX mapped massage. - -typedef struct -{ - SIG_TEST_1_t SIG_TEST_1; -} testdb_tx_t; - -#ifdef __DEF_TESTDB__ - -extern testdb_tx_t testdb_tx; - -#endif // __DEF_TESTDB__ - -#ifdef __cplusplus -} -#endif diff --git a/test/gencode/butl/ESP_testdb.c b/test/gencode/butl/ESP_testdb.c deleted file mode 100644 index 51c441e..0000000 --- a/test/gencode/butl/ESP_testdb.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "ESP_testdb.h" - -#ifdef __DEF_TESTDB__ - -testdb_rx_t testdb_rx; - -testdb_tx_t testdb_tx; - -#endif // __DEF_TESTDB__ - -uint32_t testdb_Receive(testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_) -{ - uint32_t recid = 0; - if (_id == 0x14DU) { - recid = Unpack_UTEST_2_testdb(&(_m->UTEST_2), _d, dlc_); - } else if (_id == 0x1FFFFFF6U) { - recid = Unpack_EMPTY_EXT_ID_testdb(&(_m->EMPTY_EXT_ID), _d, dlc_); - } - - return recid; -} - diff --git a/test/gencode/butl/ESP_testdb.h b/test/gencode/butl/ESP_testdb.h deleted file mode 100644 index a6c2efa..0000000 --- a/test/gencode/butl/ESP_testdb.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dbccodeconf.h" - -#include "testdb.h" - -// This version definition comes from main driver version and -// can be compared in user code space for strict compatibility test -#define VER_TESTDB_MAJ (1U) -#define VER_TESTDB_MIN (10U) - -typedef struct -{ - UTEST_2_t UTEST_2; - EMPTY_EXT_ID_t EMPTY_EXT_ID; -} testdb_rx_t; - -typedef struct -{ - EMPTY_0_t EMPTY_0; -} testdb_tx_t; - -uint32_t testdb_Receive(testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc); - -#ifdef __DEF_TESTDB__ - -extern testdb_rx_t testdb_rx; - -extern testdb_tx_t testdb_tx; - -#endif // __DEF_TESTDB__ - -#ifdef __cplusplus -} -#endif diff --git a/test/gencode/butl/bcm_testdb-binutil.c b/test/gencode/butl/bcm_testdb-binutil.c new file mode 100644 index 0000000..fc430fc --- /dev/null +++ b/test/gencode/butl/bcm_testdb-binutil.c @@ -0,0 +1,31 @@ +#include "bcm_testdb-binutil.h" + +// DBC file version +#if (VER_TESTDB_MAJ != (1U)) || (VER_TESTDB_MIN != (10U)) +#error The BCM_TESTDB binutil source file has inconsistency with core dbc lib! +#endif + +#ifdef __DEF_BCM_TESTDB__ + +bcm_testdb_rx_t bcm_testdb_rx; + +bcm_testdb_tx_t bcm_testdb_tx; + +#endif // __DEF_BCM_TESTDB__ + +uint32_t bcm_testdb_Receive(bcm_testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_) +{ + uint32_t recid = 0; + if (_id == 0x360U) { + recid = Unpack_FLT_TEST_1_testdb(&(_m->FLT_TEST_1), _d, dlc_); + } else { + if (_id == 0x777U) { + recid = Unpack_SIG_TEST_1_testdb(&(_m->SIG_TEST_1), _d, dlc_); + } else if (_id == 0x1FFFFFF6U) { + recid = Unpack_EMPTY_EXT_ID_testdb(&(_m->EMPTY_EXT_ID), _d, dlc_); + } + } + + return recid; +} + diff --git a/test/gencode/butl/bcm_testdb-binutil.h b/test/gencode/butl/bcm_testdb-binutil.h new file mode 100644 index 0000000..9a2aa30 --- /dev/null +++ b/test/gencode/butl/bcm_testdb-binutil.h @@ -0,0 +1,38 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +typedef struct +{ + FLT_TEST_1_t FLT_TEST_1; + SIG_TEST_1_t SIG_TEST_1; + EMPTY_EXT_ID_t EMPTY_EXT_ID; +} bcm_testdb_rx_t; + +typedef struct +{ + UTEST_2_t UTEST_2; + EMPTY_0_t EMPTY_0; + UTEST_3_t UTEST_3; + EMPTY_EXT_ID_t EMPTY_EXT_ID; +} bcm_testdb_tx_t; + +uint32_t bcm_testdb_Receive(bcm_testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc); + +#ifdef __DEF_BCM_TESTDB__ + +extern bcm_testdb_rx_t bcm_testdb_rx; + +extern bcm_testdb_tx_t bcm_testdb_tx; + +#endif // __DEF_BCM_TESTDB__ + +#ifdef __cplusplus +} +#endif diff --git a/test/gencode/butl/BMS_testdb.c b/test/gencode/butl/bms_testdb-binutil.c similarity index 53% rename from test/gencode/butl/BMS_testdb.c rename to test/gencode/butl/bms_testdb-binutil.c index 60526d4..23f3ba8 100644 --- a/test/gencode/butl/BMS_testdb.c +++ b/test/gencode/butl/bms_testdb-binutil.c @@ -1,14 +1,19 @@ -#include "BMS_testdb.h" +#include "bms_testdb-binutil.h" -#ifdef __DEF_TESTDB__ +// DBC file version +#if (VER_TESTDB_MAJ != (1U)) || (VER_TESTDB_MIN != (10U)) +#error The BMS_TESTDB binutil source file has inconsistency with core dbc lib! +#endif -testdb_rx_t testdb_rx; +#ifdef __DEF_BMS_TESTDB__ -testdb_tx_t testdb_tx; +bms_testdb_rx_t bms_testdb_rx; -#endif // __DEF_TESTDB__ +bms_testdb_tx_t bms_testdb_tx; -uint32_t testdb_Receive(testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_) +#endif // __DEF_BMS_TESTDB__ + +uint32_t bms_testdb_Receive(bms_testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_) { uint32_t recid = 0; if ((_id >= 0x14DU) && (_id < 0x22BU)) { diff --git a/test/gencode/butl/bms_testdb-binutil.h b/test/gencode/butl/bms_testdb-binutil.h new file mode 100644 index 0000000..fe1d027 --- /dev/null +++ b/test/gencode/butl/bms_testdb-binutil.h @@ -0,0 +1,37 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +typedef struct +{ + UTEST_2_t UTEST_2; + EMPTY_0_t EMPTY_0; + UTEST_3_t UTEST_3; + EMPTY_EXT_ID_t EMPTY_EXT_ID; +} bms_testdb_rx_t; + +typedef struct +{ + EMPTY_0_t EMPTY_0; + FLT_TEST_1_t FLT_TEST_1; +} bms_testdb_tx_t; + +uint32_t bms_testdb_Receive(bms_testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc); + +#ifdef __DEF_BMS_TESTDB__ + +extern bms_testdb_rx_t bms_testdb_rx; + +extern bms_testdb_tx_t bms_testdb_tx; + +#endif // __DEF_BMS_TESTDB__ + +#ifdef __cplusplus +} +#endif diff --git a/test/gencode/butl/eps_testdb-binutil.c b/test/gencode/butl/eps_testdb-binutil.c new file mode 100644 index 0000000..d9713a1 --- /dev/null +++ b/test/gencode/butl/eps_testdb-binutil.c @@ -0,0 +1,13 @@ +#include "eps_testdb-binutil.h" + +// DBC file version +#if (VER_TESTDB_MAJ != (1U)) || (VER_TESTDB_MIN != (10U)) +#error The EPS_TESTDB binutil source file has inconsistency with core dbc lib! +#endif + +#ifdef __DEF_EPS_TESTDB__ + +eps_testdb_tx_t eps_testdb_tx; + +#endif // __DEF_EPS_TESTDB__ + diff --git a/test/gencode/butl/eps_testdb-binutil.h b/test/gencode/butl/eps_testdb-binutil.h new file mode 100644 index 0000000..0abef17 --- /dev/null +++ b/test/gencode/butl/eps_testdb-binutil.h @@ -0,0 +1,26 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +// There is no any RX mapped massage. + +typedef struct +{ + SIG_TEST_1_t SIG_TEST_1; +} eps_testdb_tx_t; + +#ifdef __DEF_EPS_TESTDB__ + +extern eps_testdb_tx_t eps_testdb_tx; + +#endif // __DEF_EPS_TESTDB__ + +#ifdef __cplusplus +} +#endif diff --git a/test/gencode/butl/esp_testdb-binutil.c b/test/gencode/butl/esp_testdb-binutil.c new file mode 100644 index 0000000..93dd31b --- /dev/null +++ b/test/gencode/butl/esp_testdb-binutil.c @@ -0,0 +1,27 @@ +#include "esp_testdb-binutil.h" + +// DBC file version +#if (VER_TESTDB_MAJ != (1U)) || (VER_TESTDB_MIN != (10U)) +#error The ESP_TESTDB binutil source file has inconsistency with core dbc lib! +#endif + +#ifdef __DEF_ESP_TESTDB__ + +esp_testdb_rx_t esp_testdb_rx; + +esp_testdb_tx_t esp_testdb_tx; + +#endif // __DEF_ESP_TESTDB__ + +uint32_t esp_testdb_Receive(esp_testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_) +{ + uint32_t recid = 0; + if (_id == 0x14DU) { + recid = Unpack_UTEST_2_testdb(&(_m->UTEST_2), _d, dlc_); + } else if (_id == 0x1FFFFFF6U) { + recid = Unpack_EMPTY_EXT_ID_testdb(&(_m->EMPTY_EXT_ID), _d, dlc_); + } + + return recid; +} + diff --git a/test/gencode/butl/esp_testdb-binutil.h b/test/gencode/butl/esp_testdb-binutil.h new file mode 100644 index 0000000..bd3a650 --- /dev/null +++ b/test/gencode/butl/esp_testdb-binutil.h @@ -0,0 +1,34 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +typedef struct +{ + UTEST_2_t UTEST_2; + EMPTY_EXT_ID_t EMPTY_EXT_ID; +} esp_testdb_rx_t; + +typedef struct +{ + EMPTY_0_t EMPTY_0; +} esp_testdb_tx_t; + +uint32_t esp_testdb_Receive(esp_testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc); + +#ifdef __DEF_ESP_TESTDB__ + +extern esp_testdb_rx_t esp_testdb_rx; + +extern esp_testdb_tx_t esp_testdb_tx; + +#endif // __DEF_ESP_TESTDB__ + +#ifdef __cplusplus +} +#endif diff --git a/test/gencode/conf/testdb-config.h b/test/gencode/conf/testdb-config.h index 2aaa634..d273328 100644 --- a/test/gencode/conf/testdb-config.h +++ b/test/gencode/conf/testdb-config.h @@ -1,7 +1,7 @@ #pragma once /* include common dbccode configurations */ -#include "dbccodeconf.h" +#include /* ------------------------------------------------------------------------- * diff --git a/test/gencode/lib/testdb-fmon.h b/test/gencode/lib/testdb-fmon.h index 308a541..c056e9e 100644 --- a/test/gencode/lib/testdb-fmon.h +++ b/test/gencode/lib/testdb-fmon.h @@ -8,11 +8,11 @@ extern "C" { #define VER_TESTDB_MAJ_FMON (1U) #define VER_TESTDB_MIN_FMON (10U) -#include "testdb-config.h" +#include #ifdef TESTDB_USE_DIAG_MONITORS -#include "canmonitorutil.h" +#include /* This file contains the prototypes of all the functions that will be called from each Unpack_*name* function to detect DBC related errors diff --git a/test/gencode/lib/testdb.c b/test/gencode/lib/testdb.c index e72a643..a49f1ab 100644 --- a/test/gencode/lib/testdb.c +++ b/test/gencode/lib/testdb.c @@ -1,19 +1,28 @@ #include "testdb.h" +// DBC file version +#if (VER_TESTDB_MAJ != (1U)) || (VER_TESTDB_MIN != (10U)) +#error The TESTDB dbc source files have different versions +#endif + #ifdef TESTDB_USE_DIAG_MONITORS // Function prototypes to be called each time CAN frame is unpacked // FMon function may detect RC, CRC or DLC violation -#include "testdb-fmon.h" +#include #endif // TESTDB_USE_DIAG_MONITORS -// To compile this function you need to typedef 'bitext_t' and 'ubitext_t' -// globally in @dbccodeconf.h or locally in 'dbcdrvname'-config.h -// Type selection may affect common performance. Most useful types are: -// bitext_t : int64_t and ubitext_t : uint64_t -static bitext_t __ext_sig__( ubitext_t val, uint8_t bits ) +// This function performs extension of sign for the signals +// which have non-aligned to power of 2 bit's width. +// The types 'bitext_t' and 'ubitext_t' define maximal bit width which +// can be correctly handled. You need to select type which can contain +// n+1 bits where n is the largest signed signal width. For example if +// the most wide signed signal has a width of 31 bits you need to set +// bitext_t as int32_t and ubitext_t as uint32_t +// Defined these typedefs in @dbccodeconf.h or locally in 'dbcdrvname'-config.h +static bitext_t __ext_sig__(ubitext_t val, uint8_t bits) { ubitext_t const m = 1u << (bits - 1); return (val ^ m) - m; @@ -177,6 +186,7 @@ uint32_t Unpack_UTEST_3_testdb(UTEST_3_t* _m, const uint8_t* _d, uint8_t dlc_) { (void)dlc_; _m->U32_TEST_1 = ((_d[3] & (0xFFU)) << 24) | ((_d[2] & (0xFFU)) << 16) | ((_d[1] & (0xFFU)) << 8) | (_d[0] & (0xFFU)); + _m->TestValTableID = (_d[4] & (0x07U)); #ifdef TESTDB_USE_DIAG_MONITORS _m->mon1.dlc_error = (dlc_ < UTEST_3_DLC); @@ -199,6 +209,7 @@ uint32_t Pack_UTEST_3_testdb(UTEST_3_t* _m, __CoderDbcCanFrame_t__* cframe) cframe->Data[1] |= ((_m->U32_TEST_1 >> 8) & (0xFFU)); cframe->Data[2] |= ((_m->U32_TEST_1 >> 16) & (0xFFU)); cframe->Data[3] |= ((_m->U32_TEST_1 >> 24) & (0xFFU)); + cframe->Data[4] |= (_m->TestValTableID & (0x07U)); cframe->MsgId = UTEST_3_CANID; cframe->DLC = UTEST_3_DLC; @@ -216,6 +227,7 @@ uint32_t Pack_UTEST_3_testdb(UTEST_3_t* _m, uint8_t* _d, uint8_t* _len, uint8_t* _d[1] |= ((_m->U32_TEST_1 >> 8) & (0xFFU)); _d[2] |= ((_m->U32_TEST_1 >> 16) & (0xFFU)); _d[3] |= ((_m->U32_TEST_1 >> 24) & (0xFFU)); + _d[4] |= (_m->TestValTableID & (0x07U)); *_len = UTEST_3_DLC; *_ide = UTEST_3_IDE; diff --git a/test/gencode/lib/testdb.h b/test/gencode/lib/testdb.h index 3ef3753..076099a 100644 --- a/test/gencode/lib/testdb.h +++ b/test/gencode/lib/testdb.h @@ -11,14 +11,14 @@ extern "C" { #define VER_TESTDB_MIN (10U) // include current dbc-driver compilation config -#include "testdb-config.h" +#include #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" +#include #endif // TESTDB_USE_DIAG_MONITORS @@ -27,6 +27,25 @@ extern "C" { #define UTEST_2_IDE (0U) #define UTEST_2_DLC (8U) #define UTEST_2_CANID (0x14d) + +// Value tables for @ValTest signal + +#ifndef ValTest_UTEST_2_Unsupported +#define ValTest_UTEST_2_Unsupported (3) +#endif + +#ifndef ValTest_UTEST_2_Fail +#define ValTest_UTEST_2_Fail (2) +#endif + +#ifndef ValTest_UTEST_2_OK +#define ValTest_UTEST_2_OK (1) +#endif + +#ifndef ValTest_UTEST_2_Undefined +#define ValTest_UTEST_2_Undefined (0) +#endif + // signal: @U7_TEST_1_ro #define TESTDB_U7_TEST_1_ro_CovFactor (1) #define TESTDB_U7_TEST_1_ro_toS(x) ( (uint8_t) ((x) - (-255)) ) @@ -39,7 +58,6 @@ typedef struct uint32_t U28_TEST_1; // Bits=28 // This is test signal for Value Table - // // 3 : "Unsupported" // 2 : "Fail" // 1 : "OK" @@ -48,7 +66,7 @@ typedef struct uint8_t U8_TEST_1; // Bits= 8 - uint8_t U7_TEST_1_ro : 7; // Bits= 7 Offset= -255 + uint8_t U7_TEST_1_ro : 7; // Bits= 7 Offset= -255 #ifdef TESTDB_USE_SIGFLOAT int16_t U7_TEST_1_phys; @@ -59,7 +77,6 @@ typedef struct uint32_t U28_TEST_1; // Bits=28 // This is test signal for Value Table - // // 3 : "Unsupported" // 2 : "Fail" // 1 : "OK" @@ -68,7 +85,7 @@ typedef struct uint8_t U8_TEST_1; // Bits= 8 - uint8_t U7_TEST_1_ro; // Bits= 7 Offset= -255 + uint8_t U7_TEST_1_ro; // Bits= 7 Offset= -255 #ifdef TESTDB_USE_SIGFLOAT int16_t U7_TEST_1_phys; @@ -135,16 +152,77 @@ typedef struct #define UTEST_3_DLC (8U) #define UTEST_3_CANID (0x22b) +// Value tables for @TestValTableID signal + +#ifndef TestValTableID_UTEST_3_Description_for_the_value_0x7 +#define TestValTableID_UTEST_3_Description_for_the_value_0x7 (-2) +#endif + +#ifndef TestValTableID_UTEST_3_Udef +#define TestValTableID_UTEST_3_Udef (-1) +#endif + +#ifndef TestValTableID_UTEST_3_Udef +#define TestValTableID_UTEST_3_Udef (6) +#endif + +#ifndef TestValTableID_UTEST_3_Udef +#define TestValTableID_UTEST_3_Udef (5) +#endif + +#ifndef TestValTableID_UTEST_3_Udef +#define TestValTableID_UTEST_3_Udef (4) +#endif + +#ifndef TestValTableID_UTEST_3_Error +#define TestValTableID_UTEST_3_Error (3) +#endif + +#ifndef TestValTableID_UTEST_3_Ok +#define TestValTableID_UTEST_3_Ok (2) +#endif + +#ifndef TestValTableID_UTEST_3_State_one +#define TestValTableID_UTEST_3_State_one (1) +#endif + +#ifndef TestValTableID_UTEST_3_State_1 +#define TestValTableID_UTEST_3_State_1 (0) +#endif + + typedef struct { #ifdef TESTDB_USE_BITS_SIGNAL uint32_t U32_TEST_1; // Bits=32 + // -2 : "Description for the value '0x7'" + // -1 : "Udef" + // 6 : "Udef" + // 5 : "Udef" + // 4 : "Udef" + // 3 : "Error" + // 2 : "Ok" + // 1 : "State one" + // 0 : "State 1" + uint8_t TestValTableID : 3; // Bits= 3 + #else uint32_t U32_TEST_1; // Bits=32 + // -2 : "Description for the value '0x7'" + // -1 : "Udef" + // 6 : "Udef" + // 5 : "Udef" + // 4 : "Udef" + // 3 : "Error" + // 2 : "Ok" + // 1 : "State one" + // 0 : "State 1" + uint8_t TestValTableID; // Bits= 3 + #endif // TESTDB_USE_BITS_SIGNAL #ifdef TESTDB_USE_DIAG_MONITORS @@ -160,6 +238,25 @@ typedef struct #define FLT_TEST_1_DLC (8U) #define FLT_TEST_1_CANID (0x360) #define FLT_TEST_1_CYC (101U) + +// Value tables for @ValTable signal + +#ifndef ValTable_FLT_TEST_1_Unsupported +#define ValTable_FLT_TEST_1_Unsupported (3) +#endif + +#ifndef ValTable_FLT_TEST_1_Fail +#define ValTable_FLT_TEST_1_Fail (2) +#endif + +#ifndef ValTable_FLT_TEST_1_OK +#define ValTable_FLT_TEST_1_OK (1) +#endif + +#ifndef ValTable_FLT_TEST_1_Undefined +#define ValTable_FLT_TEST_1_Undefined (0) +#endif + // signal: @INT_TEST_2_ro #define TESTDB_INT_TEST_2_ro_CovFactor (5) #define TESTDB_INT_TEST_2_ro_toS(x) ( (int8_t) ((x) / (5)) ) @@ -199,7 +296,7 @@ typedef struct uint8_t Position : 4; // Bits= 4 - int8_t INT_TEST_2_ro : 7; // [-] Bits= 7 Factor= 5 + int8_t INT_TEST_2_ro : 7; // [-] Bits= 7 Factor= 5 #ifdef TESTDB_USE_SIGFLOAT int16_t INT_TEST_2_phys; @@ -217,25 +314,25 @@ typedef struct sigfloat_t Accel_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t FLT4_TEST_1_ro : 4; // Bits= 4 Offset= -0.010000 Factor= 2.010000 + uint8_t FLT4_TEST_1_ro : 4; // Bits= 4 Offset= -0.010000 Factor= 2.010000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t FLT4_TEST_1_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t FLT4_TEST_2_ro : 4; // Bits= 4 Offset= -5.000000 Factor= 2.010000 + uint8_t FLT4_TEST_2_ro : 4; // Bits= 4 Offset= -5.000000 Factor= 2.010000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t FLT4_TEST_2_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t FLT4_TEST_3_ro : 4; // Bits= 4 Offset= -10.100000 Factor= 2.000000 + uint8_t FLT4_TEST_3_ro : 4; // Bits= 4 Offset= -10.100000 Factor= 2.000000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t FLT4_TEST_3_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t INT_TEST_1_ro : 4; // Bits= 4 Offset= -11 Factor= 9 + uint8_t INT_TEST_1_ro : 4; // Bits= 4 Offset= -11 Factor= 9 #ifdef TESTDB_USE_SIGFLOAT int8_t INT_TEST_1_phys; @@ -259,7 +356,7 @@ typedef struct uint8_t Position; // Bits= 4 - int8_t INT_TEST_2_ro; // [-] Bits= 7 Factor= 5 + int8_t INT_TEST_2_ro; // [-] Bits= 7 Factor= 5 #ifdef TESTDB_USE_SIGFLOAT int16_t INT_TEST_2_phys; @@ -277,25 +374,25 @@ typedef struct sigfloat_t Accel_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t FLT4_TEST_1_ro; // Bits= 4 Offset= -0.010000 Factor= 2.010000 + uint8_t FLT4_TEST_1_ro; // Bits= 4 Offset= -0.010000 Factor= 2.010000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t FLT4_TEST_1_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t FLT4_TEST_2_ro; // Bits= 4 Offset= -5.000000 Factor= 2.010000 + uint8_t FLT4_TEST_2_ro; // Bits= 4 Offset= -5.000000 Factor= 2.010000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t FLT4_TEST_2_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t FLT4_TEST_3_ro; // Bits= 4 Offset= -10.100000 Factor= 2.000000 + uint8_t FLT4_TEST_3_ro; // Bits= 4 Offset= -10.100000 Factor= 2.000000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t FLT4_TEST_3_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t INT_TEST_1_ro; // Bits= 4 Offset= -11 Factor= 9 + uint8_t INT_TEST_1_ro; // Bits= 4 Offset= -11 Factor= 9 #ifdef TESTDB_USE_SIGFLOAT int8_t INT_TEST_1_phys; @@ -346,31 +443,31 @@ typedef struct { #ifdef TESTDB_USE_BITS_SIGNAL - int16_t sig15_ro; // [-] Bits=15 Offset= -1024 Factor= 3 + int16_t sig15_ro; // [-] Bits=15 Offset= -1024 Factor= 3 #ifdef TESTDB_USE_SIGFLOAT int32_t sig15_phys; #endif // TESTDB_USE_SIGFLOAT - int16_t sig15_2_ro; // [-] Bits=15 Offset= -2500.000000 Factor= 1.900000 + int16_t sig15_2_ro; // [-] Bits=15 Offset= -2500.000000 Factor= 1.900000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t sig15_2_phys; #endif // TESTDB_USE_SIGFLOAT - int8_t sig8_ro; // [-] Bits= 8 Factor= 5 + int8_t sig8_ro; // [-] Bits= 8 Factor= 5 #ifdef TESTDB_USE_SIGFLOAT int16_t sig8_phys; #endif // TESTDB_USE_SIGFLOAT - int8_t sig_7_ro : 7; // [-] Bits= 7 Factor= 1.200000 + int8_t sig_7_ro : 7; // [-] Bits= 7 Factor= 1.200000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t sig_7_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t U7_TEST_1_ro : 7; // Bits= 7 Offset= -255 + uint8_t U7_TEST_1_ro : 7; // Bits= 7 Offset= -255 #ifdef TESTDB_USE_SIGFLOAT int16_t U7_TEST_1_phys; @@ -378,31 +475,31 @@ typedef struct #else - int16_t sig15_ro; // [-] Bits=15 Offset= -1024 Factor= 3 + int16_t sig15_ro; // [-] Bits=15 Offset= -1024 Factor= 3 #ifdef TESTDB_USE_SIGFLOAT int32_t sig15_phys; #endif // TESTDB_USE_SIGFLOAT - int16_t sig15_2_ro; // [-] Bits=15 Offset= -2500.000000 Factor= 1.900000 + int16_t sig15_2_ro; // [-] Bits=15 Offset= -2500.000000 Factor= 1.900000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t sig15_2_phys; #endif // TESTDB_USE_SIGFLOAT - int8_t sig8_ro; // [-] Bits= 8 Factor= 5 + int8_t sig8_ro; // [-] Bits= 8 Factor= 5 #ifdef TESTDB_USE_SIGFLOAT int16_t sig8_phys; #endif // TESTDB_USE_SIGFLOAT - int8_t sig_7_ro; // [-] Bits= 7 Factor= 1.200000 + int8_t sig_7_ro; // [-] Bits= 7 Factor= 1.200000 #ifdef TESTDB_USE_SIGFLOAT sigfloat_t sig_7_phys; #endif // TESTDB_USE_SIGFLOAT - uint8_t U7_TEST_1_ro; // Bits= 7 Offset= -255 + uint8_t U7_TEST_1_ro; // Bits= 7 Offset= -255 #ifdef TESTDB_USE_SIGFLOAT int16_t U7_TEST_1_phys; @@ -423,12 +520,30 @@ typedef struct #define EMPTY_EXT_ID_DLC (8U) #define EMPTY_EXT_ID_CANID (0x1ffffff6) +// Value tables for @ValTest signal + +#ifndef ValTest_EMPTY_EXT_ID_Unsupported +#define ValTest_EMPTY_EXT_ID_Unsupported (3) +#endif + +#ifndef ValTest_EMPTY_EXT_ID_Fail +#define ValTest_EMPTY_EXT_ID_Fail (2) +#endif + +#ifndef ValTest_EMPTY_EXT_ID_OK +#define ValTest_EMPTY_EXT_ID_OK (1) +#endif + +#ifndef ValTest_EMPTY_EXT_ID_Undefined +#define ValTest_EMPTY_EXT_ID_Undefined (0) +#endif + + typedef struct { #ifdef TESTDB_USE_BITS_SIGNAL // This is test signal for Value Table - // // 3 : "Unsupported" // 2 : "Fail" // 1 : "OK" @@ -441,7 +556,6 @@ typedef struct #else // This is test signal for Value Table - // // 3 : "Unsupported" // 2 : "Fail" // 1 : "OK" diff --git a/test/gencode/usr/testdb-fmon.c b/test/gencode/usr/testdb-fmon.c index 11e7607..053af3b 100644 --- a/test/gencode/usr/testdb-fmon.c +++ b/test/gencode/usr/testdb-fmon.c @@ -1,4 +1,4 @@ -#include "testdb-fmon.h" +#include #ifdef TESTDB_USE_DIAG_MONITORS diff --git a/test/testdb.dbc b/test/testdb.dbc index d03d2d6..cbbc77f 100755 --- a/test/testdb.dbc +++ b/test/testdb.dbc @@ -34,6 +34,7 @@ NS_ : BS_: BU_: EPS ESP BMS BCM +VAL_TABLE_ VtTestSig -2 "Description for the value '0x7'" -1 "Udef" 6 "Udef" 5 "Udef" 4 "Udef" 3 "Error" 2 "Ok" 1 "State one" 0 "State 1" ; BO_ 1911 SIG_TEST_1: 8 EPS @@ -48,6 +49,7 @@ BO_ 2684354550 EMPTY_EXT_ID: 8 BCM SG_ ValTest : 7|2@0+ (1,0) [0|0] "c" BCM,ESP,BMS BO_ 555 UTEST_3: 8 BCM + SG_ TestValTableID : 32|3@1+ (1,0) [0|7] "" BMS SG_ U32_TEST_1 : 0|32@1+ (1,0) [0|4294967295] "" BMS BO_ 333 UTEST_2: 8 BCM @@ -133,6 +135,7 @@ BA_ "GenSigStartValue" SG_ 864 FLT4_TEST_1 0; BA_ "GenSigStartValue" SG_ 864 FLT4_TEST_3 5.05; BA_ "GenSigStartValue" SG_ 864 Accel 1000; VAL_ 2684354550 ValTest 3 "Unsupported" 2 "Fail" 1 "OK" 0 "Undefined" ; +VAL_ 555 TestValTableID -2 "Description for the value '0x7'" -1 "Udef" 6 "Udef" 5 "Udef" 4 "Udef" 3 "Error" 2 "Ok" 1 "State one" 0 "State 1" ; VAL_ 333 ValTest 3 "Unsupported" 2 "Fail" 1 "OK" 0 "Undefined" ; VAL_ 864 ValTable 3 "Unsupported" 2 "Fail" 1 "OK" 0 "Undefined" ; 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