From 35c22936c3ee2e77b80472acdc14e18adacd3778 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Tue, 26 Feb 2019 21:33:04 -0500 Subject: [PATCH] Allow the program to "send" frames even if no buses are configured. These frames will show up in the main frame list and can be operated on as if they came into the program. It is likely that only the playback window will work for this special use. Other sending windows are to follow. --- connections/canconmanager.cpp | 18 ++++++++++++++++++ connections/canconmanager.h | 4 +++- connections/connectionwindow.cpp | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/connections/canconmanager.cpp b/connections/canconmanager.cpp index b3428a3..56540d4 100644 --- a/connections/canconmanager.cpp +++ b/connections/canconmanager.cpp @@ -2,6 +2,7 @@ #include #include "canconmanager.h" +#include "canconfactory.h" CANConManager* CANConManager::mInstance = NULL; @@ -80,6 +81,17 @@ void CANConManager::refreshCanList() { QObject* sender_p = QObject::sender(); + if (mConns.count() == 0) + { + if(buslessFrames.size()) { + tempFrames.clear(); + tempFrames.append(buslessFrames); //make a copy and pass that copy + buslessFrames.clear(); //delete all frames from the original + emit framesReceived(nullptr, tempFrames); + } + return; + } + if( sender_p != &mTimer) { /* if we are not the sender, the signal is coming from a connection */ @@ -176,6 +188,12 @@ bool CANConManager::sendFrame(const CANFrame& pFrame) CANFrame workingFrame = pFrame; CANFrame *txFrame; + if (mConns.count() == 0) + { + buslessFrames.append(pFrame); + return true; + } + foreach (CANConnection* conn, mConns) { //check if this CAN connection is supposed to handle the requested bus diff --git a/connections/canconmanager.h b/connections/canconmanager.h index 26c6c76..5023f25 100644 --- a/connections/canconmanager.h +++ b/connections/canconmanager.h @@ -77,7 +77,9 @@ private: QElapsedTimer mElapsedTimer; uint64_t mTimestampBasis; uint32_t mNumActiveBuses; - bool useSystemTime; + bool useSystemTime; + QVector buslessFrames; + QVector tempFrames; }; #endif // CANCONNECTIONMODEL_H diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index 5ce5407..1c6ae84 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -260,6 +260,7 @@ void ConnectionWindow::handleOKButton() if( ! CANConManager::getInstance()->getByName(getPortName()) ) { /* create connection */ + //qDebug() << "Create connection type: " << getConnectionType() << " port: " << getPortName() << " driver: " << getDriverName(); conn_p = create(getConnectionType(), getPortName(), getDriverName()); if(!conn_p) return;