From 0ac26c16214470d34f111936cb7aa7da9b590602 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 8 May 2025 20:41:37 -0400 Subject: [PATCH] Fix a variety of DBC related issues, update version number at last (with plans to release soon!) --- config.h | 2 +- dbc/dbc_classes.cpp | 14 +++++++++++++- dbc/dbc_classes.h | 5 ++--- dbc/dbchandler.cpp | 3 ++- dbc/dbcmaineditor.cpp | 8 ++++++-- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/config.h b/config.h index 7849af8..2b97312 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #ifndef CONFIG #define CONFIG -#define VERSION 213 +#define VERSION 220 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision diff --git a/dbc/dbc_classes.cpp b/dbc/dbc_classes.cpp index c177e0b..a53057e 100644 --- a/dbc/dbc_classes.cpp +++ b/dbc/dbc_classes.cpp @@ -17,7 +17,10 @@ void DBC_SIGNAL::addMultiplexRange(int min, int max) if (min != max) hasExtendedMultiplexing = true; isMultiplexed = true; - multiplexLowAndHighValues.append(QPair(min, max)); + //it is very likely that things that include extended multiplexing will have at least two definitions + //which are identical. So, detect this and don't store on subsequent calls + if (!multiplexLowAndHighValues.contains(QPair(min, max))) + multiplexLowAndHighValues.append(QPair(min, max)); } bool DBC_SIGNAL::isSignalInMessage(const CANFrame &frame) @@ -76,6 +79,15 @@ void DBC_SIGNAL::copyMultiplexValuesFromSignal(const DBC_SIGNAL &signal) } } +/* + * multiplexLowAndHighValues is private but the DBC saving code needs to be able to save a reasonable value for the multiplex value + * for non-extended multiplex values. So, we grab the first element of the first item which should be the non-extended value + */ +int DBC_SIGNAL::getSimpleMultiplexValue() +{ + return multiplexLowAndHighValues.at(0).first; +} + /** * @brief DBC_SIGNAL::parseDbcMultiplexUiString * Method for parsing the Vector CANDB++ like multiplex definitions: diff --git a/dbc/dbc_classes.h b/dbc/dbc_classes.h index e37cc63..96f0839 100644 --- a/dbc/dbc_classes.h +++ b/dbc/dbc_classes.h @@ -88,7 +88,7 @@ class DBC_SIGNAL; class DBC_SIGNAL { -public: //TODO: this is sloppy. It shouldn't all be public! +public: //TODO: Clean up this class so that not everything is public. There is one private member which is a start... DBC_SIGNAL() = default; enum DbcMuxStringFormat { @@ -103,8 +103,6 @@ public: //TODO: this is sloppy. It shouldn't all be public! bool isMultiplexor = false; bool isMultiplexed = false; void addMultiplexRange(int min, int max); - int multiplexHighValue = 0; - int multiplexLowValue = 0; bool hasExtendedMultiplexing = false; QList multiplexedChildren; DBC_SIGNAL *multiplexParent = nullptr; @@ -137,6 +135,7 @@ public: //TODO: this is sloppy. It shouldn't all be public! DBC_ATTRIBUTE_VALUE *findAttrValByIdx(int idx); bool isSignalInMessage(const CANFrame &frame); bool isValueMatchingMultiplex(int val) const; + int getSimpleMultiplexValue(); friend bool operator<(const DBC_SIGNAL& l, const DBC_SIGNAL& r) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index b32e2f6..deeb55d 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -1492,7 +1492,8 @@ bool DBCFile::saveFile(QString fileName) if (sig->isMultiplexed) { - msgOutput.append(" m" + QString::number(sig->multiplexLowValue)); + msgOutput.append(" m" + QString::number(sig->getSimpleMultiplexValue())); + } if (sig->isMultiplexor) { diff --git a/dbc/dbcmaineditor.cpp b/dbc/dbcmaineditor.cpp index 50887ea..74a238c 100644 --- a/dbc/dbcmaineditor.cpp +++ b/dbc/dbcmaineditor.cpp @@ -293,8 +293,12 @@ void DBCMainEditor::onTreeDoubleClicked(const QModelIndex &index) msgID = getParentMessageID(firstCol); msg = dbcFile->messageHandler->findMsgByID(msgID); QString nameString = firstCol->text(0); - if (nameString.contains("(")) nameString = nameString.split(" ")[1]; - else nameString = nameString.split(" ")[0]; + if (nameString.contains("(")) + { + nameString = nameString.split(")")[1].trimmed(); //remove (1-2) type stuff from beginning of string + } + nameString = nameString.split(" ")[0]; //get rid of [32m 8] type stuff after the name + sig = msg->sigHandler->findSignalByName(nameString); if (sig) {