From 1c8700897016e740241cb26a930b37e2b0773f9a Mon Sep 17 00:00:00 2001 From: Ahmed Sheimy Date: Fri, 5 Aug 2022 18:32:45 +0400 Subject: [PATCH 01/37] Update canconfactory.cpp restore network connection was not working because it was detected as serial by this modification it is working --- connections/canconfactory.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connections/canconfactory.cpp b/connections/canconfactory.cpp index 1fc461c..0adb9b8 100644 --- a/connections/canconfactory.cpp +++ b/connections/canconfactory.cpp @@ -13,6 +13,9 @@ CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDri case SERIALBUS: return new SerialBusConnection(pPortName, pDriverName); case GVRET_SERIAL: + if(pPortName.contains(".")) + return new GVRetSerial(pPortName, true); + else return new GVRetSerial(pPortName, false); case REMOTE: return new GVRetSerial(pPortName, true); //it's a special case of GVRET connected over TCP/IP so it uses the same class From b6b73d0e11882e8c558b3344f0c062daa5fc8679 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Thu, 15 Sep 2022 18:39:56 -0500 Subject: [PATCH 02/37] Fixed crash when deleting a message that isn't at the bottom of the node --- dbc/dbchandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index 3bbfe01..c5cc4a5 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -192,6 +192,7 @@ bool DBCMessageHandler::removeMessage(DBC_MESSAGE *msg) { messages.removeAt(i); qDebug() << "Removed message at idx " << i; + break; } } return true; From 7e4ebf2c740c34be5f2993f3c249abc7b6273ca5 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Thu, 15 Sep 2022 18:59:24 -0500 Subject: [PATCH 03/37] Fixed nonfunctional node delete. Was due to trying to find node by name but passing in the name and comment concatenated together. Made a new function to find by name+comment since extracting only name from the text in the column would require too much guessing. --- dbc/dbchandler.cpp | 17 ++++++++++++++++- dbc/dbchandler.h | 1 + dbc/dbcmaineditor.cpp | 5 +++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index c5cc4a5..6e29ad7 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -337,7 +337,22 @@ DBC_NODE* DBCFile::findNodeByName(QString name) if (dbc_nodes.length() == 0) return nullptr; for (int i = 0; i < dbc_nodes.length(); i++) { - if (dbc_nodes[i].name.compare(name, Qt::CaseInsensitive) == 0) + if (name.compare(dbc_nodes[i].name, Qt::CaseInsensitive) == 0) + { + return &dbc_nodes[i]; + } + } + return nullptr; +} + +DBC_NODE* DBCFile::findNodeByNameAndComment(QString fullname) +{ + QString nameAndComment; + if (dbc_nodes.length() == 0) return nullptr; + for (int i = 0; i < dbc_nodes.length(); i++) + { + nameAndComment = dbc_nodes[i].name + " - " + dbc_nodes[i].comment; + if (fullname.compare(nameAndComment, Qt::CaseInsensitive) == 0) { return &dbc_nodes[i]; } diff --git a/dbc/dbchandler.h b/dbc/dbchandler.h index 304a7a8..9e040cb 100644 --- a/dbc/dbchandler.h +++ b/dbc/dbchandler.h @@ -72,6 +72,7 @@ public: DBCFile(const DBCFile& cpy); DBCFile& operator=(const DBCFile& cpy); DBC_NODE *findNodeByName(QString name); + DBC_NODE *findNodeByNameAndComment(QString fullname); DBC_NODE *findNodeByIdx(int idx); DBC_ATTRIBUTE *findAttributeByName(QString name, DBC_ATTRIBUTE_TYPE type = ATTR_TYPE_ANY); DBC_ATTRIBUTE *findAttributeByIdx(int idx); diff --git a/dbc/dbcmaineditor.cpp b/dbc/dbcmaineditor.cpp index 28e831a..54a046b 100644 --- a/dbc/dbcmaineditor.cpp +++ b/dbc/dbcmaineditor.cpp @@ -631,7 +631,7 @@ void DBCMainEditor::deleteCurrentTreeItem() { QTreeWidgetItem *currItem = ui->treeDBC->currentItem(); int typ = currItem->data(0, Qt::UserRole).toInt(); - QString idString; + QString idString, columnText; int msgID; DBC_MESSAGE *msg; DBC_NODE *node; @@ -642,7 +642,8 @@ void DBCMainEditor::deleteCurrentTreeItem() switch (typ) { case 1: //deleting a node cascades deletion down to messages and signals - node = dbcFile->findNodeByName(currItem->text(0)); + columnText = currItem->text(0); + node = dbcFile->findNodeByNameAndComment(columnText); if (!node) return; for (int x = 0; x < dbcFile->messageHandler->getCount(); x++) { From 7b966fe4a6b266c9f4da3f4ed50a7fd79414cb7d Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Fri, 16 Sep 2022 15:38:54 -0500 Subject: [PATCH 04/37] Fixed incorrect handling of partial frame tagged onto the end of a complete frame. Not sure if my method drops the partial or just sends the buffer back to continue filling. --- connections/socketcand.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index 9bbddbb..cfac211 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -263,6 +263,12 @@ void SocketCANd::decodeFrames(QString data, int busNum) QString frameStr = frameStrConst; QStringList frameParsed = (frameStr.remove(QRegExp("^<")).remove(QRegExp(">$"))).simplified().split(' '); + if(frameParsed.length() < 2) + { + qDebug() << "Received datagramm is an incomplete frame: " << data; + return; + } + buildFrame.setFrameId(frameParsed[1].toUInt(nullptr, 16)); buildFrame.bus = busNum; @@ -271,6 +277,13 @@ void SocketCANd::decodeFrames(QString data, int busNum) buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, frameParsed[2].toDouble() * 1000000l)); //buildFrame.len = frameParsed[3].length() * 0.5; + + if(frameParsed.length() < 4) + { + qDebug() << "Received frame doesn't contain any data: " << data; + return; + } + int framelength = frameParsed[3].length() * 0.5; buildData.resize(framelength); From 742956d46cd610515eb96a771d8b94ba8528cf5e Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Sat, 17 Sep 2022 12:33:15 -0500 Subject: [PATCH 05/37] Working on finding a way to prevent bad_alloc crash, temp stuff in place like prealloc size, and frames list resize (prob need to keep list below size limit to prevent chaos...10M msgs or so mabe) --- canframemodel.cpp | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 735236b..4945679 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -49,7 +49,7 @@ CANFrameModel::CANFrameModel(QObject *parent) if (QSysInfo::WordSize > 32) { qDebug() << "64 bit OS detected. Requesting a large preallocation"; - preallocSize = 10000000; + preallocSize = 10000; //000; } else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. { @@ -673,13 +673,39 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) if (!overwriteDups) { - frames.append(tempFrame); - if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus]) + bool alloc_ok = true; + + for(int i=0; i<3; i++) { - if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count()); - tempFrame.frameCount = 1; - filteredFrames.append(tempFrame); - if (autoRefresh) endInsertRows(); + try + { + if(alloc_ok == false) + { + qDebug() << "Trying to remove " << (frames.length() >> 3) << " from frames. Try #" << i ; + frames.remove(0, frames.length() >> 3); + qDebug() << "frames length now: " << (frames.length()) << "trying to alloc again" ; + alloc_ok = true; + } + + frames.append(tempFrame); + break; + } + catch (const std::exception& ex) + { + alloc_ok = false; + qDebug() << "addFrame failed to append. frames.length(): " << frames.length() << " Exception: " << ex.what(); + } + } + + if(alloc_ok) + { + if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus]) + { + if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count()); + tempFrame.frameCount = 1; + filteredFrames.append(tempFrame); + if (autoRefresh) endInsertRows(); + } } } else //yes, overwrite dups @@ -779,7 +805,7 @@ int CANFrameModel::sendBulkRefresh() if (lastUpdateNumFrames == 0 && !overwriteDups) return 0; if (filteredFrames.count() == 0) return 0; - qDebug() << "Bulk refresh of " << lastUpdateNumFrames; + //qDebug() << "Bulk refresh of " << lastUpdateNumFrames; beginResetModel(); endResetModel(); From 47d07b8bf2381370b823c7f9fac97b6f975749f5 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Sat, 17 Sep 2022 12:48:48 -0500 Subject: [PATCH 06/37] Fixed bug where switching to RAW mode would fail due to the "ok" response being received in the same message as the first data frame Sometimes when opening socketcand 1 or more busses won't start right and there's a ton of debug data saying "received datagramm: ...." It seems to happen because the switch to RAW mode is in progress and we receive the OK with a frame in the same datagramm and we don't parse the OK out of the string but rather expect the whole string to just be OK. Offending code is in socketcand.cpp SocketCANd::procRXData line 386 Fixed by looking to see if the < ok > message was at index 0 of the incoming message...could also look for it elsewhere (as in index != -1), but not sure if necessary --- canframemodel.cpp | 2 +- connections/socketcand.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 735236b..c7f5ce1 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -779,7 +779,7 @@ int CANFrameModel::sendBulkRefresh() if (lastUpdateNumFrames == 0 && !overwriteDups) return 0; if (filteredFrames.count() == 0) return 0; - qDebug() << "Bulk refresh of " << lastUpdateNumFrames; + //qDebug() << "Bulk refresh of " << lastUpdateNumFrames; beginResetModel(); endResetModel(); diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index cfac211..15db439 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -396,6 +396,12 @@ void SocketCANd::procRXData(QString data, int busNum) { rx_state[busNum] = RAWMODE; } + else if(data.indexOf("< ok >", 0, Qt::CaseSensitivity::CaseInsensitive) == 0) + { + qDebug() << "Ok found at start of compound message, switching to RAW and decoding immediately"; + rx_state[busNum] = RAWMODE; + decodeFrames(data, busNum); + } break; case RAWMODE: decodeFrames(data, busNum); From 60520b59395474e1ed585595325aee90bf0bd79d Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Sat, 17 Sep 2022 12:52:03 -0500 Subject: [PATCH 07/37] Added handing of ok message from RAW mode switch coming in out of order with other messages... For now I made it its own else statement so it can be detected --- connections/socketcand.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index 15db439..20f2ae8 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -402,6 +402,12 @@ void SocketCANd::procRXData(QString data, int busNum) rx_state[busNum] = RAWMODE; decodeFrames(data, busNum); } + else if(data.indexOf("< ok >", 0, Qt::CaseSensitivity::CaseInsensitive) > 0) + { + qDebug() << "Ok found at in middle of compound message, switching to RAW and decoding immediately"; + rx_state[busNum] = RAWMODE; + decodeFrames(data, busNum); + } break; case RAWMODE: decodeFrames(data, busNum); From 6cf404701e64695963d819c58316dfa99f5b858f Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Sat, 17 Sep 2022 13:04:39 -0500 Subject: [PATCH 08/37] Bug was due to treating an empty token as a 0, so fixed the string parsing to ignore empty tokens --- framesenderwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framesenderwindow.cpp b/framesenderwindow.cpp index 8e796ef..7029fa0 100644 --- a/framesenderwindow.cpp +++ b/framesenderwindow.cpp @@ -898,7 +898,7 @@ void FrameSenderWindow::processCellChange(int line, int col) case 6: //Data bytes for (int i = 0; i < 8; i++) sendingData[line].payload().data()[i] = 0; - tokens = ui->tableSender->item(line, 6)->text().split(" "); + tokens = ui->tableSender->item(line, 6)->text().split(" ", QString::SkipEmptyParts); arr.clear(); arr.reserve(tokens.count()); for (int j = 0; j < tokens.count(); j++) From 99640d7239437d6c3f0b8386abebe4258c33a1da Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Sat, 17 Sep 2022 13:16:02 -0500 Subject: [PATCH 09/37] Fixed data string parsing bug where an empty string created by a trailing space would be interpreted as a 0 and then added as a data byte This affected editing of the data in the table as well as loading data from a saved file --- framesenderwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framesenderwindow.cpp b/framesenderwindow.cpp index 8e796ef..7029fa0 100644 --- a/framesenderwindow.cpp +++ b/framesenderwindow.cpp @@ -898,7 +898,7 @@ void FrameSenderWindow::processCellChange(int line, int col) case 6: //Data bytes for (int i = 0; i < 8; i++) sendingData[line].payload().data()[i] = 0; - tokens = ui->tableSender->item(line, 6)->text().split(" "); + tokens = ui->tableSender->item(line, 6)->text().split(" ", QString::SkipEmptyParts); arr.clear(); arr.reserve(tokens.count()); for (int j = 0; j < tokens.count(); j++) From dfc7b095c87450649b1e1ae2661a7a8999814688 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Sat, 17 Sep 2022 13:54:59 -0500 Subject: [PATCH 10/37] Added node name as part of the signal name that gets copied into the data table --- signalviewerwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/signalviewerwindow.cpp b/signalviewerwindow.cpp index c401b49..9f926f6 100644 --- a/signalviewerwindow.cpp +++ b/signalviewerwindow.cpp @@ -105,6 +105,7 @@ void SignalViewerWindow::loadMessages() for (int f = 0; f < numFiles; f++) { qDebug() << dbcHandler->getFileByIdx(f)->messageHandler->getCount(); + for (int x = 0; x < dbcHandler->getFileByIdx(f)->messageHandler->getCount(); x++) { ui->cbMessages->addItem(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->name); @@ -140,7 +141,7 @@ void SignalViewerWindow::addSignal() int rowIdx = ui->tableViewer->rowCount(); ui->tableViewer->insertRow(rowIdx); - QTableWidgetItem *item = new QTableWidgetItem(sig->name); + QTableWidgetItem *item = new QTableWidgetItem(msg->sender->name + " - " + sig->name); ui->tableViewer->setItem(rowIdx, 0, item); } From 195c90c4154cd22ddb2e2b22489f14608e894f33 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Sun, 18 Sep 2022 13:01:34 -0500 Subject: [PATCH 11/37] change the max amount of the reserved space for the frames and filteredFrames vectors to be 99% of the capacity instead of 95%. Reset initial capacity to be 10M frames for 64-bit machines now that testing is done. Want to make the capacity adjustable by user, too. --- canframemodel.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 4945679..616978b 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -49,7 +49,7 @@ CANFrameModel::CANFrameModel(QObject *parent) if (QSysInfo::WordSize > 32) { qDebug() << "64 bit OS detected. Requesting a large preallocation"; - preallocSize = 10000; //000; + preallocSize = 10000000; } else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. { @@ -679,14 +679,6 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) { try { - if(alloc_ok == false) - { - qDebug() << "Trying to remove " << (frames.length() >> 3) << " from frames. Try #" << i ; - frames.remove(0, frames.length() >> 3); - qDebug() << "frames length now: " << (frames.length()) << "trying to alloc again" ; - alloc_ok = true; - } - frames.append(tempFrame); break; } @@ -754,6 +746,20 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) void CANFrameModel::addFrames(const CANConnection*, const QVector& pFrames) { + if(frames.length() > frames.capacity() * 0.99) + { + qDebug() << "Frames count: " << frames.length() << " of " << frames.capacity() << " capacity, removing first " << frames.capacity() * 0.05 << " frames"; + frames.remove(0, frames.capacity() * 0.05); + qDebug() << "Frames removed, new count: " << frames.length(); + } + + if(filteredFrames.length() > filteredFrames.capacity() * 0.99) + { + qDebug() << "filteredFrames count: " << filteredFrames.length() << " of " << filteredFrames.capacity() << " capacity, removing first " << filteredFrames.capacity() * 0.05 << " frames"; + filteredFrames.remove(0, filteredFrames.capacity() * 0.05); + qDebug() << "filteredFrames removed, new count: " << filteredFrames.length(); + } + foreach(const CANFrame& frame, pFrames) { addFrame(frame); From d56b35ea91bf40be0af57cd6185917d3d1588b95 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 19 Sep 2022 13:10:33 -0500 Subject: [PATCH 12/37] Made max # of frames an option in preferences, restart to take effect --- canframemodel.cpp | 10 +++++++--- mainsettingsdialog.cpp | 16 ++++++++++++++++ ui/mainsettingsdialog.ui | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 616978b..c4a8309 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "utility.h" CANFrameModel::~CANFrameModel() @@ -45,18 +46,21 @@ int CANFrameModel::columnCount(const QModelIndex &index) const CANFrameModel::CANFrameModel(QObject *parent) : QAbstractTableModel(parent) { - + int maxFramesDefault; if (QSysInfo::WordSize > 32) { qDebug() << "64 bit OS detected. Requesting a large preallocation"; - preallocSize = 10000000; + maxFramesDefault = 10000000; } else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. { qDebug() << "32 bit OS detected. Requesting a much restricted prealloc"; - preallocSize = 2000000; + maxFramesDefault = 2000000; } + QSettings settings; + int preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt(); + frames.reserve(preallocSize); filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening diff --git a/mainsettingsdialog.cpp b/mainsettingsdialog.cpp index 77bf257..2da44ed 100644 --- a/mainsettingsdialog.cpp +++ b/mainsettingsdialog.cpp @@ -90,6 +90,20 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : ui->cbFilterLabeling->setChecked(settings.value("Main/FilterLabeling", true).toBool()); ui->cbIgnoreDBCColors->setChecked(settings.value("Main/IgnoreDBCColors", false).toBool()); + int maxFramesDefault; + if (QSysInfo::WordSize > 32) + { + qDebug() << "64 bit OS detected. Requesting a large preallocation"; + maxFramesDefault = 10000000; + } + else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. + { + qDebug() << "32 bit OS detected. Requesting a much restricted prealloc"; + maxFramesDefault = 2000000; + } + + ui->spinMaximumFrames->setValue(settings.value("Main/MaximumFrames", maxFramesDefault).toInt()); + //just for simplicity they all call the same function and that function updates all settings at once connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbFlowAutoRef, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); @@ -117,6 +131,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : connect(ui->cbHexGraphFlow, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbHexGraphInfo, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbIgnoreDBCColors, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); + connect(ui->spinMaximumFrames, SIGNAL(valueChanged(int)), this, SLOT(updateSettings())); installEventFilter(this); } @@ -183,6 +198,7 @@ void MainSettingsDialog::updateSettings() settings.setValue("Remote/Pass", encPass); settings.setValue("Main/FilterLabeling", ui->cbFilterLabeling->isChecked()); settings.setValue("Main/IgnoreDBCColors", ui->cbIgnoreDBCColors->isChecked()); + settings.setValue("Main/MaximumFrames", ui->spinMaximumFrames->value()); settings.sync(); emit updatedSettings(); diff --git a/ui/mainsettingsdialog.ui b/ui/mainsettingsdialog.ui index 586e4e0..d119b08 100644 --- a/ui/mainsettingsdialog.ui +++ b/ui/mainsettingsdialog.ui @@ -80,6 +80,39 @@ + + + + 0 + + + 0 + + + + + Maximum Frames to Capture + + + + + + + 100000 + + + 1000000000 + + + 100000 + + + 10000000 + + + + + From 6fa84df7e02aea58163ca215532444e1c286989e Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 19 Sep 2022 13:31:00 -0500 Subject: [PATCH 13/37] Added ability to maintain bus and msg filters when clearing frames --- canframemodel.cpp | 13 +++++++++++-- canframemodel.h | 2 ++ mainwindow.cpp | 13 +++++++++++++ mainwindow.h | 1 + ui/mainwindow.ui | 7 +++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index c4a8309..8ca4a5a 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -67,6 +67,7 @@ CANFrameModel::CANFrameModel(QObject *parent) dbcHandler = DBCHandler::getReference(); interpretFrames = false; overwriteDups = false; + filtersPersistDuringClear = false; useHexMode = true; timeSeconds = false; timeOffset = 0; @@ -200,6 +201,11 @@ void CANFrameModel::setOverwriteMode(bool mode) endResetModel(); } +void CANFrameModel::setClearMode(bool mode) +{ + filtersPersistDuringClear = mode; +} + void CANFrameModel::setFilterState(unsigned int ID, bool state) { if (!filters.contains(ID)) return; @@ -832,8 +838,11 @@ void CANFrameModel::clearFrames() this->beginResetModel(); frames.clear(); filteredFrames.clear(); - filters.clear(); - busFilters.clear(); + if(filtersPersistDuringClear == false) + { + filters.clear(); + busFilters.clear(); + } frames.reserve(preallocSize); filteredFrames.reserve(preallocSize); this->endResetModel(); diff --git a/canframemodel.h b/canframemodel.h index edb65b5..49ad74d 100644 --- a/canframemodel.h +++ b/canframemodel.h @@ -46,6 +46,7 @@ public: bool getInterpretMode(); void setOverwriteMode(bool); void setHexMode(bool); + void setClearMode(bool mode); void setSysTimeMode(bool); void setMillisMode(bool mode); void setIgnoreDBCColors(bool mode); @@ -89,6 +90,7 @@ private: QMutex mutex; bool interpretFrames; //should we use the dbcHandler? bool overwriteDups; //should we display all frames or only the newest for each ID? + bool filtersPersistDuringClear; QString timeFormat; bool useHexMode; bool timeSeconds; diff --git a/mainwindow.cpp b/mainwindow.cpp index f32125a..1923063 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -141,6 +141,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->cbInterpret, &QAbstractButton::toggled, this, &MainWindow::interpretToggled); connect(ui->cbOverwrite, &QAbstractButton::toggled, this, &MainWindow::overwriteToggled); + connect(ui->cbPersistentFilters, &QAbstractButton::toggled, this, &MainWindow::presistentFiltersToggled); connect(ui->listFilters, &QListWidget::itemChanged, this, &MainWindow::filterListItemChanged); connect(ui->listBusFilters, &QListWidget::itemChanged, this, &MainWindow::busFilterListItemChanged); @@ -616,6 +617,18 @@ void MainWindow::overwriteToggled(bool state) } } +void MainWindow::presistentFiltersToggled(bool state) +{ + if (state) + { + model->setClearMode(true); + } + else + { + model->setClearMode(false); + } +} + void MainWindow::updateFilterList() { if (model == nullptr) return; diff --git a/mainwindow.h b/mainwindow.h index 0b0fd90..39bb612 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -99,6 +99,7 @@ private slots: void setupSendToLatestGraphWindow(); void interpretToggled(bool); void overwriteToggled(bool); + void presistentFiltersToggled(bool state); void logReceivedFrame(CANConnection*, QVector); void tickGUIUpdate(); void toggleCapture(); diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 4fb01d8..77e1b5a 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -227,6 +227,13 @@ + + + + Keep Filters When Clearing + + + From cb94cac2057cab2121bccfce0f4255e100e017bb Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 19 Sep 2022 13:47:57 -0500 Subject: [PATCH 14/37] Fixed issue where filteredFrames was having its capacity changed when adjusting filters due to appending a QVector of frames which appears to change the capacity to the number of items appended. Also fixed bug where preallocsize was being locally defined and therefore the global version wasn't being updated with unknown effets. --- canframemodel.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index c4a8309..cdcaa19 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -59,7 +59,7 @@ CANFrameModel::CANFrameModel(QObject *parent) } QSettings settings; - int preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt(); + preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt(); frames.reserve(preallocSize); filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening @@ -752,15 +752,15 @@ void CANFrameModel::addFrames(const CANConnection*, const QVector& pFr { if(frames.length() > frames.capacity() * 0.99) { - qDebug() << "Frames count: " << frames.length() << " of " << frames.capacity() << " capacity, removing first " << frames.capacity() * 0.05 << " frames"; - frames.remove(0, frames.capacity() * 0.05); + qDebug() << "Frames count: " << frames.length() << " of " << frames.capacity() << " capacity, removing first " << (int)(frames.capacity() * 0.05) << " frames"; + frames.remove(0, (int)(frames.capacity() * 0.05)); qDebug() << "Frames removed, new count: " << frames.length(); } if(filteredFrames.length() > filteredFrames.capacity() * 0.99) { - qDebug() << "filteredFrames count: " << filteredFrames.length() << " of " << filteredFrames.capacity() << " capacity, removing first " << filteredFrames.capacity() * 0.05 << " frames"; - filteredFrames.remove(0, filteredFrames.capacity() * 0.05); + qDebug() << "filteredFrames count: " << filteredFrames.length() << " of " << filteredFrames.capacity() << " capacity, removing first " << (int)(filteredFrames.capacity() * 0.05) << " frames"; + filteredFrames.remove(0, (int)(filteredFrames.capacity() * 0.05)); qDebug() << "filteredFrames removed, new count: " << filteredFrames.length(); } @@ -790,8 +790,8 @@ void CANFrameModel::sendRefresh() mutex.lock(); beginResetModel(); filteredFrames.clear(); - filteredFrames.reserve(preallocSize); filteredFrames.append(tempContainer); + filteredFrames.reserve(preallocSize); lastUpdateNumFrames = 0; endResetModel(); From 40dbf253afcef48b21a601d4ea7fba24641fd9d5 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 19 Sep 2022 15:28:53 -0500 Subject: [PATCH 15/37] Saving, loading, clearing, and appending signal lists working!! --- mainwindow.cpp | 19 ++++- signalviewerwindow.cpp | 174 ++++++++++++++++++++++++++++++++++++++- signalviewerwindow.h | 8 ++ ui/signalviewerwindow.ui | 28 +++++++ 4 files changed, 226 insertions(+), 3 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 1923063..4617956 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1159,11 +1159,26 @@ void MainWindow::showTemporalGraphWindow() //only create an instance of the object if we dont have one. Otherwise just display the existing one. if (!temporalGraphWindow) { + const QVector *frames; if (!useFiltered) - temporalGraphWindow = new TemporalGraphWindow(model->getListReference()); + frames = model->getListReference(); else - temporalGraphWindow = new TemporalGraphWindow(model->getFilteredListReference()); + frames = model->getFilteredListReference(); + + if(frames->count() > 2000) + { + QMessageBox::StandardButton confirmDialog; + confirmDialog = QMessageBox::question(this, "Danger Will Robinson", "There are a lot of frames (>2000) to plot, this may take a while or crash the app. Crash likely with more than 10k frames. Continue?", + QMessageBox::Yes|QMessageBox::No); + if (confirmDialog == QMessageBox::No) + { + return; + } + } + + temporalGraphWindow = new TemporalGraphWindow(frames); } + temporalGraphWindow->show(); } diff --git a/signalviewerwindow.cpp b/signalviewerwindow.cpp index 9f926f6..cb70364 100644 --- a/signalviewerwindow.cpp +++ b/signalviewerwindow.cpp @@ -27,6 +27,10 @@ SignalViewerWindow::SignalViewerWindow(const QVector *frames, QWidget connect(ui->btnAdd, SIGNAL(clicked(bool)), this, SLOT(addSignal())); connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int))); connect(ui->btnRemove, SIGNAL(clicked(bool)), this, SLOT(removeSelectedSignal())); + connect(ui->btnSave, SIGNAL(clicked(bool)), this, SLOT(saveSignalsFile())); + connect(ui->btnLoad, SIGNAL(clicked(bool)), this, SLOT(loadSignalsFile())); + connect(ui->btnAppend, SIGNAL(clicked(bool)), this, SLOT(appendSignalsFile())); + connect(ui->btnClear, SIGNAL(clicked(bool)), this, SLOT(clearSignalsTable())); loadMessages(); } @@ -137,11 +141,179 @@ void SignalViewerWindow::addSignal() DBC_SIGNAL *sig = msg->sigHandler->findSignalByName(ui->cbSignals->currentText()); if (!sig) return; + addSignal(sig); +} + +void SignalViewerWindow::addSignal(DBC_SIGNAL *sig) +{ signalList.append(sig); int rowIdx = ui->tableViewer->rowCount(); ui->tableViewer->insertRow(rowIdx); - QTableWidgetItem *item = new QTableWidgetItem(msg->sender->name + " - " + sig->name); + QTableWidgetItem *item = new QTableWidgetItem(sig->parentMessage->sender->name + " - " + sig->name); ui->tableViewer->setItem(rowIdx, 0, item); +} +void SignalViewerWindow::saveSignalsFile() +{ + saveDefinitions(); +} + +void SignalViewerWindow::loadSignalsFile() +{ + loadDefinitions(false); +} + +void SignalViewerWindow::appendSignalsFile() +{ + loadDefinitions(true); +} + +void SignalViewerWindow::clearSignalsTable() +{ + clearSignalsTable(true); +} + +void SignalViewerWindow::clearSignalsTable(bool askForConfirmation) +{ + if(askForConfirmation) + { + QMessageBox::StandardButton confirmDialog; + confirmDialog = QMessageBox::question(this, "Danger Will Robinson", "Are you sure you want to clear all of your signals?", + QMessageBox::Yes|QMessageBox::No); + if (confirmDialog == QMessageBox::No) + { + return; + } + } + + signalList.clear(); + ui->tableViewer->setRowCount(0); +} + +void SignalViewerWindow::saveDefinitions() +{ + QString filename; + QFileDialog dialog(this); + QSettings settings; + + QStringList filters; + filters.append(QString(tr("SignalViewer definition (*.sdf)"))); + + dialog.setFileMode(QFileDialog::AnyFile); + dialog.setNameFilters(filters); + dialog.setViewMode(QFileDialog::Detail); + dialog.setAcceptMode(QFileDialog::AcceptSave); + dialog.setDirectory(settings.value("SignalViewer/LoadSaveDirectory", dialog.directory().path()).toString()); + + if (dialog.exec() == QDialog::Accepted) + { + filename = dialog.selectedFiles()[0]; + settings.setValue("SignalViewer/LoadSaveDirectory", dialog.directory().path()); + + if (!filename.contains('.')) filename += ".sdf"; + + QFile *outFile = new QFile(filename); + + if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + DBC_SIGNAL *sig; + for (int i = 0; i < signalList.count(); i++) + { + sig = signalList.at(i); + + outFile->write("SV1"); + outFile->putChar(','); + outFile->write(QString::number(sig->parentMessage->ID, 16).toUtf8()); + outFile->putChar(','); + outFile->write(sig->parentMessage->name.toUtf8()); + outFile->putChar(','); + outFile->write(sig->name.toUtf8()); + + outFile->write("\n"); + } + outFile->close(); + } +} + +void SignalViewerWindow::loadDefinitions(bool append) +{ + QString filename; + QFileDialog dialog; + QSettings settings; + + QStringList filters; + filters.append(QString(tr("SignalViewer definition (*.sdf)"))); + + QList loadedSignals; + + if (dbcHandler == nullptr) return; + if (dbcHandler->getFileCount() == 0) dbcHandler->createBlankFile(); + + dialog.setFileMode(QFileDialog::ExistingFile); + dialog.setNameFilters(filters); + dialog.setViewMode(QFileDialog::Detail); + dialog.setDirectory(settings.value("SignalViewer/LoadSaveDirectory", dialog.directory().path()).toString()); + + if (dialog.exec() == QDialog::Accepted) + { + filename = dialog.selectedFiles()[0]; + settings.setValue("SignalViewer/LoadSaveDirectory", dialog.directory().path()); + + QFile *inFile = new QFile(filename); + QByteArray line; + + if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text)) + return; + + while (!inFile->atEnd()) { + line = inFile->readLine().simplified(); + if (line.length() > 2) + { + QList tokens = line.split(','); + + DBC_SIGNAL *sig; + + if (tokens[0] == "SV1") //signal viewer save format v1 + { + // = tokens[1].toUInt(nullptr, 16); + + int msgId = tokens[1].toUInt(nullptr, 16); + QString msgName = QString(tokens[2]); + QString sigName = QString(tokens[3]); + DBC_MESSAGE *msg;; + if (msg = dbcHandler->findMessage(msgName)) + { + sig = msg->sigHandler->findSignalByName(sigName); + loadedSignals.append(sig); + } + else if(msg = dbcHandler->findMessage(msgId)) + { + sig = msg->sigHandler->findSignalByName(sigName); + //fix anything up about the name? + loadedSignals.append(sig); + } + else + { + qDebug() << "Couldn't find the message by name! " << msgName << " " << sigName; + } + } + } + } + inFile->close(); + + if(loadedSignals.count() > 0) + { + if(append == false) + { + clearSignalsTable(false); + } + + for (int i=0; i + + + + Save View + + + + + + + Load View + + + + + + + Append to View + + + + + + + Clear View + + + From 9e9195b34e51220ca89d836e1282bc27fb554d4b Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 19 Sep 2022 16:13:30 -0500 Subject: [PATCH 16/37] changed default data table font to be fixed-width for easier reading --- mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 4617956..a77ea1f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -55,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent) : verticalHeader->setSectionResizeMode(QHeaderView::Fixed); QSettings settings; int fontSize = settings.value("Main/FontSize", 9).toUInt(); - QFont sysFont = QFont(); //get default font + QFont sysFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); //get default font sysFont.setPointSize(fontSize); verticalHeader->setDefaultSectionSize(sysFont.pixelSize()); ui->canFramesView->setFont(sysFont); From 13c920f97110128ece5642c41f31d2208a71d5f4 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Tue, 20 Sep 2022 07:46:30 -0500 Subject: [PATCH 17/37] Fixed regression where non-commented node would not delete Fixed odd crash due to dbcNode being null on refresh --- dbc/dbchandler.cpp | 6 +++++- dbc/dbcnodeeditor.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index 6e29ad7..d60dd1b 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -351,7 +351,11 @@ DBC_NODE* DBCFile::findNodeByNameAndComment(QString fullname) if (dbc_nodes.length() == 0) return nullptr; for (int i = 0; i < dbc_nodes.length(); i++) { - nameAndComment = dbc_nodes[i].name + " - " + dbc_nodes[i].comment; + if(dbc_nodes[i].comment.isEmpty()) + nameAndComment = dbc_nodes[i].name; + else + nameAndComment = dbc_nodes[i].name + " - " + dbc_nodes[i].comment; + if (fullname.compare(nameAndComment, Qt::CaseInsensitive) == 0) { return &dbc_nodes[i]; diff --git a/dbc/dbcnodeeditor.cpp b/dbc/dbcnodeeditor.cpp index e8363a3..f553fb4 100644 --- a/dbc/dbcnodeeditor.cpp +++ b/dbc/dbcnodeeditor.cpp @@ -111,8 +111,11 @@ void DBCNodeEditor::showEvent(QShowEvent* event) void DBCNodeEditor::refreshView() { - ui->lineComment->setText(dbcNode->comment); - ui->lineMsgName->setText(dbcNode->name); + if(dbcNode) + { + ui->lineComment->setText(dbcNode->comment); + ui->lineMsgName->setText(dbcNode->name); + } //generateSampleText(); } From f38e0b0bfaecd7197fa00cae2e7d9dfd1100b637 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Fri, 23 Sep 2022 15:28:41 -0500 Subject: [PATCH 18/37] Took out unnecessary exception recover code Cuz app is going to crash anyway, no need to make a mess --- canframemodel.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 8ca4a5a..94f3ce0 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -61,8 +61,9 @@ CANFrameModel::CANFrameModel(QObject *parent) QSettings settings; int preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt(); + //the goal is to prevent a reallocation from ever happening frames.reserve(preallocSize); - filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening + filteredFrames.reserve(preallocSize); dbcHandler = DBCHandler::getReference(); interpretFrames = false; @@ -685,18 +686,14 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) { bool alloc_ok = true; - for(int i=0; i<3; i++) + try { - try - { - frames.append(tempFrame); - break; - } - catch (const std::exception& ex) - { - alloc_ok = false; - qDebug() << "addFrame failed to append. frames.length(): " << frames.length() << " Exception: " << ex.what(); - } + frames.append(tempFrame); + } + catch (const std::exception& ex) + { + alloc_ok = false; + qDebug() << "addFrame failed to append. App is probably going to crash. frames.length(): " << frames.length() << " Exception: " << ex.what(); } if(alloc_ok) From 5ffe161210aef98a51068234ead07b391ab0d34f Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Fri, 23 Sep 2022 15:30:58 -0500 Subject: [PATCH 19/37] more clean up --- canframemodel.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 94f3ce0..df75171 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -684,20 +684,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) if (!overwriteDups) { - bool alloc_ok = true; - try { frames.append(tempFrame); - } - catch (const std::exception& ex) - { - alloc_ok = false; - qDebug() << "addFrame failed to append. App is probably going to crash. frames.length(): " << frames.length() << " Exception: " << ex.what(); - } - if(alloc_ok) - { if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus]) { if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count()); @@ -706,6 +696,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) if (autoRefresh) endInsertRows(); } } + catch (const std::exception& ex) + { + qDebug() << "addFrame failed to append. App is probably going to crash. frames.length(): " << frames.length() << " Exception: " << ex.what(); + } } else //yes, overwrite dups { From 07db2874070bf836da82ce092f948429e12d6221 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Sat, 24 Sep 2022 17:27:39 +0200 Subject: [PATCH 20/37] replace qrand/qsrand with QRandomGenerator (qt6) Since Qt5, qrand/qsrand methods [are deprecated](https://doc.qt.io/qt-5/qtglobal-obsolete.html#qrand). Qt6 remove those methods, thus we need to use instead a [QRandomGenerator](https://doc.qt.io/qt-6/qrandomgenerator.html). QElapsedTimer is available since Qt5.10, and is already used in the source code. --- scriptingwindow.cpp | 11 ++++++++++- simplecrypt.cpp | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/scriptingwindow.cpp b/scriptingwindow.cpp index 1d5f378..1f24dee 100644 --- a/scriptingwindow.cpp +++ b/scriptingwindow.cpp @@ -4,6 +4,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) +#include +#endif #include "connections/canconmanager.h" #include "helpwindow.h" @@ -234,7 +237,13 @@ void ScriptingWindow::createNewScript() container = new ScriptContainer(); - container->fileName = "UNNAMED_" + QString::number((qrand() % 10000)) + ".js"; + QString randomPart; +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) + randomPart = QString::number((qrand() % 10000)); +#else + randomPart = QString::number((QRandomGenerator::global()->bounded(10000))); +#endif + container->fileName = "UNNAMED_" + randomPart + ".js"; container->filePath = QString(); container->scriptText = QString(); container->setScriptWindow(this); diff --git a/simplecrypt.cpp b/simplecrypt.cpp index 79a16ba..51f4271 100644 --- a/simplecrypt.cpp +++ b/simplecrypt.cpp @@ -31,6 +31,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) +#include +#endif SimpleCrypt::SimpleCrypt(): m_key(0), @@ -38,7 +42,9 @@ SimpleCrypt::SimpleCrypt(): m_protectionMode(ProtectionChecksum), m_lastError(ErrorNoError) { +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF)); +#endif } SimpleCrypt::SimpleCrypt(quint64 key): @@ -47,7 +53,9 @@ SimpleCrypt::SimpleCrypt(quint64 key): m_protectionMode(ProtectionChecksum), m_lastError(ErrorNoError) { +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF)); +#endif splitKey(); } @@ -113,7 +121,11 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) } //prepend a random char to the string +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) char randomChar = char(qrand() & 0xFF); +#else + char randomChar = char(QRandomGenerator::global()->bounded(256)); +#endif ba = randomChar + integrityProtection + ba; int pos(0); From 9fb86e649ff436dd78755c9405e93ddc2d52b428 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Sat, 24 Sep 2022 17:51:25 +0200 Subject: [PATCH 21/37] remove qRegisterMetaTypeStreamOperators (qt6) Since Qt6, some methods of [QMetaType are removed](https://doc.qt.io/qt-6/qtcore-changes-qt6.html#the-qmetatype-class). We remove `qRegisterMetaTypeStreamOperators()` calls for Qt >= 6 --- connections/connectionwindow.cpp | 2 ++ mainwindow.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index a446078..e277e58 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -501,8 +501,10 @@ CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName, QS void ConnectionWindow::loadConnections() { +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators>(); +#endif QSettings settings; diff --git a/mainwindow.cpp b/mainwindow.cpp index f32125a..24c013d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -30,8 +30,10 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { ui->setupUi(this); +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) qRegisterMetaTypeStreamOperators>(); qRegisterMetaTypeStreamOperators>(); +#endif useHex = true; From 5a18c611e1e056e4f34952d3bce160304343fe93 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Sat, 24 Sep 2022 17:04:26 +0200 Subject: [PATCH 22/37] replace QTime with QElapsedTimer when possible (qt6) Since Qt5, some methods of QTime [are deprecated](https://doc.qt.io/qt-5/qtime-obsolete.html). Qt6 remove those methods, thus in two instances we need to use a [QElapsedTimer](https://doc.qt.io/qt-6/qelapsedtimer.html) instead of a QTime. QElapsedTimer is available since Qt5.4, and is already used in the source code. --- mainwindow.cpp | 2 +- mainwindow.h | 2 +- re/sniffer/snifferitem.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index f32125a..ee9da8c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -177,7 +177,7 @@ MainWindow::MainWindow(QWidget *parent) : updateTimer.setInterval(250); updateTimer.start(); - elapsedTime = new QTime; + elapsedTime = new QElapsedTimer; elapsedTime->start(); isConnected = false; diff --git a/mainwindow.h b/mainwindow.h index 0b0fd90..b4febdb 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -137,7 +137,7 @@ private: DBCHandler *dbcHandler; QByteArray inputBuffer; QTimer updateTimer; - QTime *elapsedTime; + QElapsedTimer *elapsedTime; int framesPerSec; int rxFrames; bool inhibitFilterUpdate; diff --git a/re/sniffer/snifferitem.h b/re/sniffer/snifferitem.h index 0995a10..ea0a086 100644 --- a/re/sniffer/snifferitem.h +++ b/re/sniffer/snifferitem.h @@ -2,7 +2,7 @@ #define SNIFFERITEM_H #include -#include +#include #include "can_structs.h" struct fstCan @@ -50,7 +50,7 @@ private: quint64 mCurrentTime; quint64 mCurrSeqVal; - QTime mTime; + QElapsedTimer mTime; }; #endif // SNIFFERITEM_H From c2fc1f179ec2265a28305d93a840fe22e2de9a15 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Sat, 24 Sep 2022 22:06:09 +0200 Subject: [PATCH 23/37] replace BackgroundColorRole/TextColorRole with BackgroundRole/ForegroundRole (qt6) Since long time ago (12yrs), Qt::BackgroundColorRole/Qt::TextColorRole are aliased by Qt::BackgroundRole/Qt::ForegroundRole and raise a deprecation warning. Qt6 remove those values, thus we need to use Qt::BackgroundRole/Qt::ForegroundRole. --- canframemodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index cdcaa19..c69080f 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -408,7 +408,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const const unsigned char *data = reinterpret_cast(thisFrame.payload().constData()); int dataLen = thisFrame.payload().count(); - if (role == Qt::BackgroundColorRole) + if (role == Qt::BackgroundRole) { if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors) { @@ -441,7 +441,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const } } - if (role == Qt::TextColorRole) + if (role == Qt::ForegroundRole) { if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors) { From 5ac5a7d45f2cbca2c0af3daf76068d12b51398c4 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Sat, 24 Sep 2022 22:13:02 +0200 Subject: [PATCH 24/37] replace QAtomicInt load()/store() with loadRelaxed()/storeRelaxed() Since Qt5, some methods of QAtomicInteger [are deprecated](https://doc.qt.io/qt-5/qatomicinteger-obsolete.html). Qt6 remove those methods, thus we need to replace them. --- connections/canconnection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connections/canconnection.cpp b/connections/canconnection.cpp index 8f0e231..ba145ee 100644 --- a/connections/canconnection.cpp +++ b/connections/canconnection.cpp @@ -245,11 +245,11 @@ CANCon::type CANConnection::getType() { CANCon::status CANConnection::getStatus() { - return (CANCon::status) mStatus.load(); + return (CANCon::status) mStatus.loadRelaxed(); } void CANConnection::setStatus(CANCon::status pStatus) { - mStatus.store(pStatus); + mStatus.storeRelaxed(pStatus); } bool CANConnection::isCapSuspended() { From 97844ad1e546295248c311db4f4d28f071245c50 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Sat, 24 Sep 2022 22:22:15 +0200 Subject: [PATCH 25/37] make QCustomPlot compatible with Qt6.2+ (qt6) Cf the discussion here: https://www.qcustomplot.com/index.php/support/forum/2380 --- qcustomplot.h | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/qcustomplot.h b/qcustomplot.h index 8f0f78b..170850b 100644 --- a/qcustomplot.h +++ b/qcustomplot.h @@ -156,26 +156,8 @@ class QCPPolarGraph; It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject. */ -#ifndef Q_MOC_RUN namespace QCP { -#else -class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace - Q_GADGET - Q_ENUMS(ExportPen) - Q_ENUMS(ResolutionUnit) - Q_ENUMS(SignDomain) - Q_ENUMS(MarginSide) - Q_FLAGS(MarginSides) - Q_ENUMS(AntialiasedElement) - Q_FLAGS(AntialiasedElements) - Q_ENUMS(PlottingHint) - Q_FLAGS(PlottingHints) - Q_ENUMS(Interaction) - Q_FLAGS(Interactions) - Q_ENUMS(SelectionRectMode) - Q_ENUMS(SelectionType) -public: -#endif + Q_NAMESPACE /*! Defines the different units in which the image resolution can be specified in the export @@ -318,6 +300,20 @@ enum SelectionType { stNone ///< The plottable is not selectable ,stMultipleDataRanges ///< Any combination of data points/ranges can be selected }; + Q_ENUM_NS(ExportPen) + Q_ENUM_NS(ResolutionUnit) + Q_ENUM_NS(SignDomain) + Q_ENUM_NS(MarginSide) + Q_FLAG_NS(MarginSides) + Q_ENUM_NS(AntialiasedElement) + Q_FLAG_NS(AntialiasedElements) + Q_ENUM_NS(PlottingHint) + Q_FLAG_NS(PlottingHints) + Q_ENUM_NS(Interaction) + Q_FLAG_NS(Interactions) + Q_ENUM_NS(SelectionRectMode) + Q_ENUM_NS(SelectionType) + /*! \internal Returns whether the specified \a value is considered an invalid data value for plottables (i.e. @@ -386,15 +382,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) -Q_DECLARE_METATYPE(QCP::ExportPen) -Q_DECLARE_METATYPE(QCP::ResolutionUnit) -Q_DECLARE_METATYPE(QCP::SignDomain) -Q_DECLARE_METATYPE(QCP::MarginSide) -Q_DECLARE_METATYPE(QCP::AntialiasedElement) -Q_DECLARE_METATYPE(QCP::PlottingHint) -Q_DECLARE_METATYPE(QCP::Interaction) -Q_DECLARE_METATYPE(QCP::SelectionRectMode) -Q_DECLARE_METATYPE(QCP::SelectionType) +//no need to use Q_DECLARE_METATYPE on enum since Q_ENUM_NS adds enum as metatype automatically /* end of 'src/global.h' */ From 768ebf9966fbdef2cbdf91cc31d9cf56677b74a2 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Tue, 27 Sep 2022 21:04:19 +0200 Subject: [PATCH 26/37] replace `QString::SkipEmptyParts` with `Qt::SkipEmptyParts` (qt6) `QString::SkipEmptyParts` is [deprecated since around Qt5.14](https://doc.qt.io/qt-5/qstring-obsolete.html), and has been removed in Qt6. We replace it with `Qt::SkipEmptyParts` for Qt >= 5.14 --- framesenderwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framesenderwindow.cpp b/framesenderwindow.cpp index 7029fa0..4d66317 100644 --- a/framesenderwindow.cpp +++ b/framesenderwindow.cpp @@ -898,7 +898,11 @@ void FrameSenderWindow::processCellChange(int line, int col) case 6: //Data bytes for (int i = 0; i < 8; i++) sendingData[line].payload().data()[i] = 0; +#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) + tokens = ui->tableSender->item(line, 6)->text().split(" ", Qt::SkipEmptyParts); +#else tokens = ui->tableSender->item(line, 6)->text().split(" ", QString::SkipEmptyParts); +#endif arr.clear(); arr.reserve(tokens.count()); for (int j = 0; j < tokens.count(); j++) From bcbe3d38bd981569cc7d57a2c27126b66395861a Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Tue, 27 Sep 2022 21:29:03 +0200 Subject: [PATCH 27/37] Use enums from `Qt::ItemFlags` It seems that one my compiler we need to use an explicit enum instead of the constant it represents. It shouldn't cause any issue as the value is the same. --- re/sniffer/sniffermodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/re/sniffer/sniffermodel.cpp b/re/sniffer/sniffermodel.cpp index 55736b4..293a69d 100644 --- a/re/sniffer/sniffermodel.cpp +++ b/re/sniffer/sniffermodel.cpp @@ -137,7 +137,7 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const Qt::ItemFlags SnifferModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return Qt::NoItemFlags; return QAbstractItemModel::flags(index); } From 74388791bf3aada1c9b0b3a8336738e4be5d643c Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Tue, 27 Sep 2022 21:10:37 +0200 Subject: [PATCH 28/37] remove `QSerialPort` obsolete enum values (qt6) Three enums (`QSerialPort::ParityError`, `QSerialPort::FramingError`, `QSerialPort::BreakConditionError`) are [deprecated since Qt5.6](https://doc.qt.io/qt-5/qserialport.html) and removed from Qt6. We remove them, it's unfortunate but I don't know how to replace these - it seems that we need to handle those in an [OS-specific way](https://codereview.qt-project.org/c/qt/qtserialport/+/125517/). --- connections/gvretserial.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index c307b44..d6a122c 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -485,6 +485,7 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err) killConnection = true; piStop(); break; +#if QT_VERSION <= QT_VERSION_CHECK( 6, 0, 0 ) case QSerialPort::ParityError: errMessage = "Parity error on serial port"; break; @@ -494,6 +495,7 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err) case QSerialPort::BreakConditionError: errMessage = "Break error on serial port"; break; +#endif case QSerialPort::WriteError: errMessage = "Write error on serial port"; piStop(); From 1af5cbacc6efa519ffec512b72da2a231671ece8 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Tue, 27 Sep 2022 22:09:30 +0200 Subject: [PATCH 29/37] fix QMqtt ambiguous conversion Prevent error: ``` moc_qmqtt_client.cpp:459:53: error: conversion from 'QMQTT::ConnectionState' to 'QChar' is ambiguous ``` --- mqtt/qmqtt_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mqtt/qmqtt_client.h b/mqtt/qmqtt_client.h index da89f01..690319b 100644 --- a/mqtt/qmqtt_client.h +++ b/mqtt/qmqtt_client.h @@ -129,7 +129,7 @@ class Q_MQTT_EXPORT Client : public QObject Q_PROPERTY(quint8 _willQos READ willQos WRITE setWillQos) Q_PROPERTY(bool _willRetain READ willRetain WRITE setWillRetain) Q_PROPERTY(QByteArray _willMessage READ willMessage WRITE setWillMessage) - Q_PROPERTY(QString _connectionState READ connectionState) + Q_PROPERTY(ConnectionState _connectionState READ connectionState) #ifndef QT_NO_SSL Q_PROPERTY(QSslConfiguration _sslConfiguration READ sslConfiguration WRITE setSslConfiguration) #endif // QT_NO_SSL From 5002f3ebec8a8c35b87bf731e9149c7dcd4f4500 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Tue, 27 Sep 2022 22:15:47 +0200 Subject: [PATCH 30/37] fix some static cast errors in QMqtt The following error occurs twice: ``` mqtt/qmqtt_ssl_socket.cpp:49:13: error: static_cast from 'QAbstractSocket::SocketError (QAbstractSocket::*)() const' to 'void (QSslSocket::*)(QAbstractSocket::SocketError)' is not allowed ``` It may not be the cleanest fix but the it is the only one I could come with... --- mqtt/qmqtt_socket.cpp | 4 ++-- mqtt/qmqtt_ssl_socket.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mqtt/qmqtt_socket.cpp b/mqtt/qmqtt_socket.cpp index f0628f0..5805f94 100644 --- a/mqtt/qmqtt_socket.cpp +++ b/mqtt/qmqtt_socket.cpp @@ -41,9 +41,9 @@ QMQTT::Socket::Socket(QObject* parent) connect(_socket.data(), &QTcpSocket::connected, this, &SocketInterface::connected); connect(_socket.data(), &QTcpSocket::disconnected, this, &SocketInterface::disconnected); connect(_socket.data(), - static_cast(&QTcpSocket::error), + SIGNAL(error(QTcpSocket::error)), this, - static_cast(&SocketInterface::error)); + SLOT(errorHandler(SocketInterface::error))); } QMQTT::Socket::~Socket() diff --git a/mqtt/qmqtt_ssl_socket.cpp b/mqtt/qmqtt_ssl_socket.cpp index 2d3a808..9f70434 100644 --- a/mqtt/qmqtt_ssl_socket.cpp +++ b/mqtt/qmqtt_ssl_socket.cpp @@ -46,9 +46,9 @@ QMQTT::SslSocket::SslSocket(const QSslConfiguration& config, QObject* parent) connect(_socket.data(), &QSslSocket::encrypted, this, &SocketInterface::connected); connect(_socket.data(), &QSslSocket::disconnected, this, &SocketInterface::disconnected); connect(_socket.data(), - static_cast(&QSslSocket::error), + SIGNAL(error(QSslSocket::error)), this, - static_cast(&SocketInterface::error)); + SLOT(errorHandler(SocketInterface::error))); connect(_socket.data(), static_cast&)>(&QSslSocket::sslErrors), this, From 88e51a4a326850577d5577aada2f44d6de345dac Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Tue, 27 Sep 2022 23:01:58 +0200 Subject: [PATCH 31/37] remove obsolete `QWheelEvent::delta()` (qt6) The function `QWheelEvent::delta()` is [deprecated in Qt5](https://doc.qt.io/qt-5/qwheelevent-obsolete.html#delta), and has been removed in Qt6. We port it to `QWheelEvent::angleDelta()`. --- jsedit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsedit.cpp b/jsedit.cpp index 5a994d0..edb1eef 100644 --- a/jsedit.cpp +++ b/jsedit.cpp @@ -931,7 +931,8 @@ void JSEdit::resizeEvent(QResizeEvent *e) void JSEdit::wheelEvent(QWheelEvent *e) { if (e->modifiers() == Qt::ControlModifier) { - int steps = e->delta() / 20; + QPoint numDegrees = e->angleDelta(); + int steps = numDegrees.y() / 20; steps = qBound(-3, steps, 3); QFont textFont = font(); int pointSize = textFont.pointSize() + steps; From b8039f9b163f879b1bf2a4cb6e2b781ac858a66c Mon Sep 17 00:00:00 2001 From: bigoulours Date: Wed, 28 Sep 2022 15:42:19 +0200 Subject: [PATCH 32/37] Priorizing exact match over J1939 and GMLAN Hi Collin, I had a case where two ECUs were sending the same PGN (with different contents though), leading to SavvyCAN picking the first found PGN-Match. Hence my proposal: go over the list until an exact match is found, otherwise returning the best match (same PGN). --- dbc/dbchandler.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index d60dd1b..8290c10 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -100,8 +100,15 @@ void DBCSignalHandler::sort() DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) { if (messages.count() == 0) return nullptr; + DBC_MESSAGE *bestMatch = nullptr; + for (int i = 0; i < messages.count(); i++) { + if ( messages[i].ID == id ) + { + return &messages[i]; + } + if (matchingCriteria == J1939) { // include data page and extended data page in the pgn @@ -112,7 +119,7 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) pgn &= 0x3FF00; if ((messages[i].ID & 0x3FF0000) == (pgn << 8)) { - return &messages[i]; + bestMatch = &messages[i]; } } else @@ -120,7 +127,7 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) // PDU2 format if ((messages[i].ID & 0x3FFFF00) == (pgn << 8)) { - return &messages[i]; + bestMatch = &messages[i]; } } } @@ -129,17 +136,10 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) // Match the bits 14-26 (Arbitration Id) of GMLAN 29bit header uint32_t arbId = id &0x3FFE000; if ( (arbId != 0) && (messages[i].ID & 0x3FFE000) == arbId ) - return &messages[i]; - } - else - { - if ( messages[i].ID == id ) - { - return &messages[i]; - } + bestMatch = &messages[i]; } } - return nullptr; + return bestMatch; } DBC_MESSAGE* DBCMessageHandler::findMsgByIdx(int idx) From bd8582b8e36626fdb1ee8df46e297b9799fc028c Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Wed, 28 Sep 2022 20:02:27 -0500 Subject: [PATCH 33/37] Added combobox for nodes so msg combobox isnt so long Added disabled filenames in node combobox so you can understand what is what Added node column to table Made table columns sortable so you can sort by node name or message name Want to make table fixed width font capable Want to make table rearrangable Want to make table rows shorter to fix more info in a window Want to make it possible to have multiple signal viewer windows Want to add ability to click on signals and add them to graphs like the main window --- signalviewerwindow.cpp | 75 ++++++++++++++++++++++++++++++++++------ signalviewerwindow.h | 3 +- ui/signalviewerwindow.ui | 16 ++++++++- 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/signalviewerwindow.cpp b/signalviewerwindow.cpp index cb70364..7d20531 100644 --- a/signalviewerwindow.cpp +++ b/signalviewerwindow.cpp @@ -4,6 +4,9 @@ #include "mainwindow.h" #include +#define MSG_COL 1 +#define VALUE_COL 2 + SignalViewerWindow::SignalViewerWindow(const QVector *frames, QWidget *parent) : QDialog(parent), ui(new Ui::SignalViewerWindow) @@ -14,15 +17,16 @@ SignalViewerWindow::SignalViewerWindow(const QVector *frames, QWidget modelFrames = frames; QStringList headers; - headers << "Signal" << "Value"; + headers << "Node" << "Signal" << "Value"; ui->tableViewer->setHorizontalHeaderLabels(headers); - ui->tableViewer->setColumnWidth(0, 150); - ui->tableViewer->setColumnWidth(1, 300); + ui->tableViewer->setColumnWidth(0, 100); + ui->tableViewer->setColumnWidth(1, 150); QHeaderView *HorzHdr = ui->tableViewer->horizontalHeader(); HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview dbcHandler = DBCHandler::getReference(); + connect(ui->cbNodes, SIGNAL(currentIndexChanged(int)), this, SLOT(loadMessages(int))); connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int))); connect(ui->btnAdd, SIGNAL(clicked(bool)), this, SLOT(addSignal())); connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int))); @@ -32,7 +36,7 @@ SignalViewerWindow::SignalViewerWindow(const QVector *frames, QWidget connect(ui->btnAppend, SIGNAL(clicked(bool)), this, SLOT(appendSignalsFile())); connect(ui->btnClear, SIGNAL(clicked(bool)), this, SLOT(clearSignalsTable())); - loadMessages(); + loadNodes(); } SignalViewerWindow::~SignalViewerWindow() @@ -79,11 +83,11 @@ void SignalViewerWindow::processFrame(CANFrame &frame) { if (sig->processAsText(frame, sigString, false)) //if true we could interpret the signal so update it in the list { - QTableWidgetItem *item = ui->tableViewer->item(i, 1); + QTableWidgetItem *item = ui->tableViewer->item(i, VALUE_COL); if (!item) { item = new QTableWidgetItem(sigString); - ui->tableViewer->setItem(i, 1, item); + ui->tableViewer->setItem(i, VALUE_COL, item); } else item->setText(sigString); } @@ -99,20 +103,67 @@ void SignalViewerWindow::removeSelectedSignal() ui->tableViewer->removeRow(selRow); } -void SignalViewerWindow::loadMessages() +void SetComboBoxItemEnabled(QComboBox * comboBox, int index, bool enabled) +{ + auto * model = qobject_cast(comboBox->model()); + assert(model); + if(!model) return; + + auto * item = model->item(index); + assert(item); + if(!item) return; + item->setEnabled(enabled); +} + +void SignalViewerWindow::loadNodes() { int numFiles; - ui->cbMessages->clear(); + ui->cbNodes->clear(); if (dbcHandler == nullptr) return; if ((numFiles = dbcHandler->getFileCount()) == 0) return; qDebug() << numFiles; + for (int f = 0; f < numFiles; f++) + { + qDebug() << dbcHandler->getFileByIdx(f)->messageHandler->getCount(); + + QList names; + + for (int x = 0; x < dbcHandler->getFileByIdx(f)->dbc_nodes.count(); x++) + { + QString name = dbcHandler->getFileByIdx(f)->dbc_nodes[x].name; + if(name != "Vector__XXX") + names.append(name); + } + + if(names.count() > 0) + { + names.sort(); + ui->cbNodes->addItem("----" + dbcHandler->getFileByIdx(f)->getFilename()); + SetComboBoxItemEnabled(ui->cbNodes, ui->cbNodes->count() -1, false); + for(int i=0; icbNodes->addItem(names[i]); + } + } +} + +void SignalViewerWindow::loadMessages(int idx) +{ + int numFiles; + ui->cbMessages->clear(); + if (dbcHandler == nullptr) return; + if ((numFiles = dbcHandler->getFileCount()) == 0) return; + qDebug() << numFiles; + + QString nodeName = ui->cbNodes->itemText(idx); + for (int f = 0; f < numFiles; f++) { qDebug() << dbcHandler->getFileByIdx(f)->messageHandler->getCount(); for (int x = 0; x < dbcHandler->getFileByIdx(f)->messageHandler->getCount(); x++) { - ui->cbMessages->addItem(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->name); + if(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->sender->name == nodeName) + ui->cbMessages->addItem(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->name); } } } @@ -150,8 +201,10 @@ void SignalViewerWindow::addSignal(DBC_SIGNAL *sig) int rowIdx = ui->tableViewer->rowCount(); ui->tableViewer->insertRow(rowIdx); - QTableWidgetItem *item = new QTableWidgetItem(sig->parentMessage->sender->name + " - " + sig->name); - ui->tableViewer->setItem(rowIdx, 0, item); + QTableWidgetItem *nodeitem = new QTableWidgetItem(sig->parentMessage->sender->name); + ui->tableViewer->setItem(rowIdx, 0, nodeitem); + QTableWidgetItem *msgitem = new QTableWidgetItem(sig->name); + ui->tableViewer->setItem(rowIdx, 1, msgitem); } void SignalViewerWindow::saveSignalsFile() diff --git a/signalviewerwindow.h b/signalviewerwindow.h index fab979c..711fe2c 100644 --- a/signalviewerwindow.h +++ b/signalviewerwindow.h @@ -17,7 +17,8 @@ public: ~SignalViewerWindow(); private slots: - void loadMessages(); + void loadNodes(); + void loadMessages(int idx); void loadSignals(int idx); void addSignal(); void addSignal(DBC_SIGNAL *sig); diff --git a/ui/signalviewerwindow.ui b/ui/signalviewerwindow.ui index 0814757..8f1c75d 100644 --- a/ui/signalviewerwindow.ui +++ b/ui/signalviewerwindow.ui @@ -18,8 +18,11 @@ + + true + - 2 + 3 300 @@ -32,6 +35,7 @@ + @@ -45,6 +49,16 @@ + + + + Node + + + + + + From dc0b25bee8e569113ba5f942987656060cc79fa3 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Fri, 30 Sep 2022 16:33:07 -0500 Subject: [PATCH 34/37] Added setting for fixed width vs normal font in the data tables --- mainsettingsdialog.cpp | 3 +++ mainwindow.cpp | 8 +++++++- signalviewerwindow.cpp | 15 +++++++++++++++ ui/mainsettingsdialog.ui | 18 ++++++++++++++++-- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/mainsettingsdialog.cpp b/mainsettingsdialog.cpp index 2da44ed..7cd1230 100644 --- a/mainsettingsdialog.cpp +++ b/mainsettingsdialog.cpp @@ -48,6 +48,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : ui->cbLoadConnections->setChecked(settings.value("Main/SaveRestoreConnections", false).toBool()); ui->spinFontSize->setValue(settings.value("Main/FontSize", ui->cbDisplayHex->font().pointSize()).toUInt()); + ui->cbFontFixedWidth->setChecked(settings.value("Main/FontFixedWidth", false).toBool()); bool secondsMode = settings.value("Main/TimeSeconds", false).toBool(); bool clockMode = settings.value("Main/TimeClock", false).toBool(); @@ -132,6 +133,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : connect(ui->cbHexGraphInfo, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbIgnoreDBCColors, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->spinMaximumFrames, SIGNAL(valueChanged(int)), this, SLOT(updateSettings())); + connect(ui->cbFontFixedWidth, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); installEventFilter(this); } @@ -199,6 +201,7 @@ void MainSettingsDialog::updateSettings() settings.setValue("Main/FilterLabeling", ui->cbFilterLabeling->isChecked()); settings.setValue("Main/IgnoreDBCColors", ui->cbIgnoreDBCColors->isChecked()); settings.setValue("Main/MaximumFrames", ui->spinMaximumFrames->value()); + settings.setValue("Main/FontFixedWidth", ui->cbFontFixedWidth->isChecked()); settings.sync(); emit updatedSettings(); diff --git a/mainwindow.cpp b/mainwindow.cpp index e1184f1..e84da30 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -57,12 +57,18 @@ MainWindow::MainWindow(QWidget *parent) : verticalHeader->setSectionResizeMode(QHeaderView::Fixed); QSettings settings; int fontSize = settings.value("Main/FontSize", 9).toUInt(); - QFont sysFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); //get default font + QFont sysFont; + if(settings.value("Main/FontFixedWidth", false).toBool()) + sysFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); //get default fixed width font + else + sysFont = QFont(); //get default font sysFont.setPointSize(fontSize); verticalHeader->setDefaultSectionSize(sysFont.pixelSize()); + verticalHeader->setFont(QFont()); ui->canFramesView->setFont(sysFont); QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader(); + HorzHdr->setFont(QFont()); HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview connect(HorzHdr, SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int))); diff --git a/signalviewerwindow.cpp b/signalviewerwindow.cpp index 7d20531..c061074 100644 --- a/signalviewerwindow.cpp +++ b/signalviewerwindow.cpp @@ -21,8 +21,23 @@ SignalViewerWindow::SignalViewerWindow(const QVector *frames, QWidget ui->tableViewer->setHorizontalHeaderLabels(headers); ui->tableViewer->setColumnWidth(0, 100); ui->tableViewer->setColumnWidth(1, 150); + + QSettings settings; + QFont sysFont; + int fontSize = settings.value("Main/FontSize", 9).toUInt(); + if(settings.value("Main/FontFixedWidth", false).toBool()) + sysFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); //get default fixed width font + else + sysFont = QFont(); //get default font + sysFont.setPointSize(fontSize); + ui->tableViewer->setFont(sysFont); + QHeaderView *HorzHdr = ui->tableViewer->horizontalHeader(); HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview + HorzHdr->setFont(QFont()); + + QHeaderView *verticalHeader = ui->tableViewer->verticalHeader(); + verticalHeader->setFont(QFont()); dbcHandler = DBCHandler::getReference(); diff --git a/ui/mainsettingsdialog.ui b/ui/mainsettingsdialog.ui index d119b08..cb61d4d 100644 --- a/ui/mainsettingsdialog.ui +++ b/ui/mainsettingsdialog.ui @@ -7,7 +7,7 @@ 0 0 965 - 678 + 713 @@ -191,9 +191,23 @@ - Font Size + Font + + + + Use fixed-width font in tables + + + + + + + Size + + + From 08953a4004128c182a603819fd09b99313f419f7 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 3 Oct 2022 11:26:28 -0500 Subject: [PATCH 35/37] Improved socketcand input buffer handling to reduce lost data. No longer tossing partial frames, saving the data to concat with future data. On startup there can be some data loss, but after it gets rolling there is none. Added rough provision to ensure the buffer doesn't get filled with bad data, but the decodeFrames recursive calls do a pretty good job of getting rid of it so I haven't seen the buffer grow after millions of frames coming over a UDP-based VPN. --- connections/socketcand.cpp | 53 ++++++++++++++++++++++++++++++-------- connections/socketcand.h | 3 ++- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index 20f2ae8..90f2408 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -249,24 +249,38 @@ void SocketCANd::switchToRawMode(int busNum) QCoreApplication::processEvents(); } -void SocketCANd::decodeFrames(QString data, int busNum) +QString SocketCANd::decodeFrames(QString data, int busNum) { if (data.indexOf("< frame ") == -1) { - qDebug() << "Received datagramm doesn't contain any frame: " << data; - return; + //qDebug() << "Received datagramm doesn't contain any frame: " << data; + if (data.indexOf("<") == -1) + return ""; + else + return data; } else { - QString framePart = data.mid(data.indexOf("< frame "), data.length()); //remove starting beginning of payload if not < frame > + int firstIndex = data.indexOf("< frame "); + if(firstIndex > 0) + { + QString framePartial = data.left(firstIndex); + qDebug() << "Received datagramm that starts with fragment (missing '< frame'), this should only occur on startup, removing...: " << framePartial; + } + QString framePart = data.mid(firstIndex, data.length()); //remove starting beginning of payload if not < frame > const QString frameStrConst = framePart.left(framePart.indexOf(">")+1); QString frameStr = frameStrConst; QStringList frameParsed = (frameStr.remove(QRegExp("^<")).remove(QRegExp(">$"))).simplified().split(' '); if(frameParsed.length() < 2) { - qDebug() << "Received datagramm is an incomplete frame: " << data; - return; + //qDebug() << "Received datagramm is an incomplete frame: " << data; + + //ok great, need to leave it in the buffer in case it can be combined with what comes next + //but if there was a fragment that did not have a starting token then we don't want it so only return + //known good data...again this should only happen on startup, but just in case we need to remove it + //so the data buffer doesn't grow uncontrolled. + return framePart; } buildFrame.setFrameId(frameParsed[1].toUInt(nullptr, 16)); @@ -281,7 +295,7 @@ void SocketCANd::decodeFrames(QString data, int busNum) if(frameParsed.length() < 4) { qDebug() << "Received frame doesn't contain any data: " << data; - return; + return data; } int framelength = frameParsed[3].length() * 0.5; @@ -315,8 +329,12 @@ void SocketCANd::decodeFrames(QString data, int busNum) else qDebug() << "can't get a frame, capture suspended"; + //take out the data that we just processed and anything that is in front of it + //this should keep broken frames from accumulating at in the data buffer if (framePart.length() > frameStrConst.length()) - decodeFrames(framePart.right(framePart.length() - frameStrConst.length()), busNum); + return decodeFrames(framePart.right(framePart.length() - frameStrConst.length()), busNum); + + return ""; } } @@ -400,17 +418,30 @@ void SocketCANd::procRXData(QString data, int busNum) { qDebug() << "Ok found at start of compound message, switching to RAW and decoding immediately"; rx_state[busNum] = RAWMODE; - decodeFrames(data, busNum); + unprocessedData = decodeFrames(data, busNum); } else if(data.indexOf("< ok >", 0, Qt::CaseSensitivity::CaseInsensitive) > 0) { qDebug() << "Ok found at in middle of compound message, switching to RAW and decoding immediately"; rx_state[busNum] = RAWMODE; - decodeFrames(data, busNum); + unprocessedData = decodeFrames(data, busNum); } break; case RAWMODE: - decodeFrames(data, busNum); + if(!unprocessedData.isEmpty()) + { + //qDebug() << unprocessedData.length() << " bytes of unprocessedData: " << unprocessedData << " adding it to new data: " + data.left(50) + "..."; + } + unprocessedData = decodeFrames(unprocessedData + data, busNum); + + if(unprocessedData.length() > 128) + { + //the buffer has grown too much we need to clear it out, but what is good logic for that? + //the decodeFrames function strips out datat that doesn't have a '< frame' starting token, and in its + //recursive calling of itself it strips out data that preceedes valid frames, so this should never happen + qDebug() << unprocessedData.length() << " bytes in unprocessedData, something is wrong, clearing..."; + unprocessedData.clear(); + } break; case ISOTP: break; diff --git a/connections/socketcand.h b/connections/socketcand.h index b5c9376..bd86e33 100644 --- a/connections/socketcand.h +++ b/connections/socketcand.h @@ -57,7 +57,7 @@ private slots: void invokeReadTCPData(); void deviceConnected(int busNum); void switchToRawMode(int busNum); - void decodeFrames(QString, int busNum); + QString decodeFrames(QString, int busNum); private: void procRXData(QString, int busNum); @@ -76,6 +76,7 @@ protected: QByteArray buildData; QVarLengthArray rx_state; CANFrame buildFrame; + QString unprocessedData; }; From e52a74ac7a464e94fefaec44c0c5b1f94a95431e Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 3 Oct 2022 16:36:30 -0500 Subject: [PATCH 36/37] Found a bug where complete frames being removed from the buffer were being shorted by 1 character Committing now with debug comments for future reference --- connections/socketcand.cpp | 160 ++++++++++++++++++------------------- connections/socketcand.h | 2 +- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index 90f2408..c290204 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -32,6 +32,7 @@ SocketCANd::SocketCANd(QString portName) : for (int i = 0; i < mNumBuses; i++) { rx_state.append(IDLE); + unprocessedData.append(""); } } @@ -251,91 +252,87 @@ void SocketCANd::switchToRawMode(int busNum) QString SocketCANd::decodeFrames(QString data, int busNum) { - if (data.indexOf("< frame ") == -1) + if (data.indexOf("<") == -1) + return ""; + else if(data.length() >= 8 && data.indexOf("< frame ") == -1) + return ""; + + int firstIndex = data.indexOf("< frame "); + if(firstIndex > 0) { - //qDebug() << "Received datagramm doesn't contain any frame: " << data; - if (data.indexOf("<") == -1) - return ""; - else - return data; + QString framePartial = data.left(firstIndex); + qDebug() << "Received datagramm that starts with fragment (missing '< frame'), this should only occur on startup, removing...: " << framePartial; } - else + QString framePart = data.mid(firstIndex); //remove starting beginning of payload if not < frame > + const QString frameStrConst = framePart.left(framePart.indexOf(">")+1); + QString frameStr = frameStrConst; + QStringList frameParsed = (frameStr.remove(QRegExp("^<")).remove(QRegExp(">$"))).simplified().split(' '); + + if(frameParsed.length() < 3) { - int firstIndex = data.indexOf("< frame "); - if(firstIndex > 0) - { - QString framePartial = data.left(firstIndex); - qDebug() << "Received datagramm that starts with fragment (missing '< frame'), this should only occur on startup, removing...: " << framePartial; - } - QString framePart = data.mid(firstIndex, data.length()); //remove starting beginning of payload if not < frame > - const QString frameStrConst = framePart.left(framePart.indexOf(">")+1); - QString frameStr = frameStrConst; - QStringList frameParsed = (frameStr.remove(QRegExp("^<")).remove(QRegExp(">$"))).simplified().split(' '); + //qDebug() << "Received datagramm is an incomplete frame: " << data; - if(frameParsed.length() < 2) - { - //qDebug() << "Received datagramm is an incomplete frame: " << data; + //ok great, need to leave it in the buffer in case it can be combined with what comes next + //but if there was a fragment that did not have a starting token then we don't want it so only return + //known good data...again this should only happen on startup, but just in case we need to remove it + //so the data buffer doesn't grow uncontrolled. + return framePart; + } - //ok great, need to leave it in the buffer in case it can be combined with what comes next - //but if there was a fragment that did not have a starting token then we don't want it so only return - //known good data...again this should only happen on startup, but just in case we need to remove it - //so the data buffer doesn't grow uncontrolled. - return framePart; - } + buildFrame.setFrameId(frameParsed[1].toUInt(nullptr, 16)); + buildFrame.bus = busNum; - buildFrame.setFrameId(frameParsed[1].toUInt(nullptr, 16)); - buildFrame.bus = busNum; + if (buildFrame.frameId() > 0x7FF) buildFrame.setExtendedFrameFormat(true); + else buildFrame.setExtendedFrameFormat(false); - if (buildFrame.frameId() > 0x7FF) buildFrame.setExtendedFrameFormat(true); - else buildFrame.setExtendedFrameFormat(false); + buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, frameParsed[2].toDouble() * 1000000l)); + //buildFrame.len = frameParsed[3].length() * 0.5; - buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, frameParsed[2].toDouble() * 1000000l)); - //buildFrame.len = frameParsed[3].length() * 0.5; + if(frameParsed.length() < 4) + { + qDebug() << "Received frame doesn't contain any data: " << data; + return data; + } - if(frameParsed.length() < 4) - { - qDebug() << "Received frame doesn't contain any data: " << data; - return data; - } + int framelength = frameParsed[3].length() * 0.5; - int framelength = frameParsed[3].length() * 0.5; + buildData.resize(framelength); - buildData.resize(framelength); - - int c; - for (c = 0; c < framelength; c++) - { - bool ok; - unsigned char byteVal = frameParsed[3].mid(c*2, 2).toUInt(&ok, 16); - buildData[c] = byteVal; - } - buildFrame.setPayload(buildData); + int c; + for (c = 0; c < framelength; c++) + { + bool ok; + unsigned char byteVal = frameParsed[3].mid(c*2, 2).toUInt(&ok, 16); + buildData[c] = byteVal; + } + buildFrame.setPayload(buildData); // buildFrame.isReceived = true; - if (!isCapSuspended()) - { - /* get frame from queue */ - CANFrame* frame_p = getQueue().get(); - if(frame_p) { - /* copy frame */ - *frame_p = buildFrame; - //frame_p->remote = false; - frame_p->setFrameType(QCanBusFrame::DataFrame); - checkTargettedFrame(buildFrame); - /* enqueue frame */ - getQueue().queue(); - } + if (!isCapSuspended()) + { + /* get frame from queue */ + CANFrame* frame_p = getQueue().get(); + if(frame_p) { + /* copy frame */ + *frame_p = buildFrame; + //frame_p->remote = false; + frame_p->setFrameType(QCanBusFrame::DataFrame); + checkTargettedFrame(buildFrame); + /* enqueue frame */ + getQueue().queue(); } - else - qDebug() << "can't get a frame, capture suspended"; - - //take out the data that we just processed and anything that is in front of it - //this should keep broken frames from accumulating at in the data buffer - if (framePart.length() > frameStrConst.length()) - return decodeFrames(framePart.right(framePart.length() - frameStrConst.length()), busNum); - - return ""; } + else + qDebug() << "can't get a frame, capture suspended"; + + //take out the data that we just processed and anything that is in front of it + //this should keep broken frames from accumulating at in the data buffer + if (framePart.length() > frameStrConst.length()) + { + return decodeFrames(framePart.right(framePart.length() - frameStrConst.length()), busNum); + } + + return ""; } void SocketCANd::disconnectDevice() { @@ -405,6 +402,7 @@ void SocketCANd::procRXData(QString data, int busNum) { switchToRawMode(busNum); rx_state[busNum] = SWITCHING2RAW; + unprocessedData[busNum].clear(); } else qInfo() << hostCanIDs[busNum] << ": Could not open bus. Host did not respond with ""< ok >"": " << data; break; @@ -418,29 +416,31 @@ void SocketCANd::procRXData(QString data, int busNum) { qDebug() << "Ok found at start of compound message, switching to RAW and decoding immediately"; rx_state[busNum] = RAWMODE; - unprocessedData = decodeFrames(data, busNum); + unprocessedData[busNum] = decodeFrames(data, busNum); } else if(data.indexOf("< ok >", 0, Qt::CaseSensitivity::CaseInsensitive) > 0) { qDebug() << "Ok found at in middle of compound message, switching to RAW and decoding immediately"; rx_state[busNum] = RAWMODE; - unprocessedData = decodeFrames(data, busNum); + unprocessedData[busNum] = decodeFrames(data, busNum); } break; case RAWMODE: - if(!unprocessedData.isEmpty()) - { - //qDebug() << unprocessedData.length() << " bytes of unprocessedData: " << unprocessedData << " adding it to new data: " + data.left(50) + "..."; - } - unprocessedData = decodeFrames(unprocessedData + data, busNum); + //if(!unprocessedData[busNum].isEmpty()) + //{ + // qDebug() << "busNum: " << busNum << "- " << unprocessedData[busNum].length() << " bytes of unprocessedData: " << unprocessedData[busNum] << " adding it to new data: " + data.left(50) + "..."; + // } + unprocessedData[busNum] = decodeFrames(unprocessedData[busNum] + data, busNum); + //if(unprocessedData[busNum].length() > 0) + // qDebug() << "busNum: " << busNum << " has data left over, what was at the end of the last packet?: " << data.right(20); - if(unprocessedData.length() > 128) + if(unprocessedData[busNum].length() > 128) { //the buffer has grown too much we need to clear it out, but what is good logic for that? //the decodeFrames function strips out datat that doesn't have a '< frame' starting token, and in its //recursive calling of itself it strips out data that preceedes valid frames, so this should never happen - qDebug() << unprocessedData.length() << " bytes in unprocessedData, something is wrong, clearing..."; - unprocessedData.clear(); + qDebug() << "busNum: " << busNum << "- " << unprocessedData[busNum].length() << " bytes in unprocessedData, something is wrong, clearing..."; + unprocessedData[busNum].clear(); } break; case ISOTP: diff --git a/connections/socketcand.h b/connections/socketcand.h index bd86e33..aa8510a 100644 --- a/connections/socketcand.h +++ b/connections/socketcand.h @@ -76,7 +76,7 @@ protected: QByteArray buildData; QVarLengthArray rx_state; CANFrame buildFrame; - QString unprocessedData; + QVarLengthArray unprocessedData; }; From 3c07785040461c2cddad0f691ada5ae0fb57d765 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 3 Oct 2022 17:02:13 -0500 Subject: [PATCH 37/37] Buffer for partially received and/or leftover frame fragments now working with multiple active busses. Removed commented out test code and put a fix in for for the filters list not having its capacity properly reserved in recalcOverwrite so multiple entries of the same message show up in the filtered view --- canframemodel.cpp | 1 + connections/socketcand.cpp | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index e061a57..5f84930 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -381,6 +381,7 @@ void CANFrameModel::recalcOverwrite() //Then replace the old list of frames with just the unique list frames.clear(); frames.append(overWriteFrames.values().toVector()); + frames.reserve(preallocSize); filteredFrames.clear(); filteredFrames.reserve(preallocSize); diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index c290204..8a6e5da 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -426,13 +426,7 @@ void SocketCANd::procRXData(QString data, int busNum) } break; case RAWMODE: - //if(!unprocessedData[busNum].isEmpty()) - //{ - // qDebug() << "busNum: " << busNum << "- " << unprocessedData[busNum].length() << " bytes of unprocessedData: " << unprocessedData[busNum] << " adding it to new data: " + data.left(50) + "..."; - // } unprocessedData[busNum] = decodeFrames(unprocessedData[busNum] + data, busNum); - //if(unprocessedData[busNum].length() > 0) - // qDebug() << "busNum: " << busNum << " has data left over, what was at the end of the last packet?: " << data.right(20); if(unprocessedData[busNum].length() > 128) {