diff --git a/SavvyCAN.pro.user b/SavvyCAN.pro.user index 9279630..b97025f 100644 --- a/SavvyCAN.pro.user +++ b/SavvyCAN.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/frameplaybackwindow.cpp b/frameplaybackwindow.cpp index 857d513..14ee853 100644 --- a/frameplaybackwindow.cpp +++ b/frameplaybackwindow.cpp @@ -1,5 +1,6 @@ #include "frameplaybackwindow.h" #include "ui_frameplaybackwindow.h" +#include FramePlaybackWindow::FramePlaybackWindow(QList *frames, QWidget *parent) : QDialog(parent), @@ -202,9 +203,10 @@ void FramePlaybackWindow::updatePosition(bool forward) if (idList.at(0)->checkState() == Qt::Checked) { //index 0 is none, 1 is Bus 0, 2 is bus 1, 3 is both, 4 is from file - //if (whichBusSend & 1) parent.SendCANFrame(modelFrames->at(currentPosition), 0); - //if (whichBusSend & 2) parent.SendCANFrame(modelFrames->at(currentPosition), 1); - //if (whichBusSend & 4) parent.SendCANFrame(modelFrames->at(currentPosition), loadedFrames[playbackPos].bus); + const CANFrame *thisFrame = &modelFrames->at(currentPosition); + if (whichBusSend & 1) emit sendCANFrame(thisFrame, 0); + if (whichBusSend & 2) emit sendCANFrame(thisFrame, 1); + if (whichBusSend & 4) emit sendCANFrame(thisFrame, thisFrame->bus); updateFrameLabel(); } } diff --git a/frameplaybackwindow.h b/frameplaybackwindow.h index f08521d..d4a8be3 100644 --- a/frameplaybackwindow.h +++ b/frameplaybackwindow.h @@ -33,6 +33,9 @@ private slots: void btnSelectNoneClick(); void timerTriggered(); +signals: + void sendCANFrame(const CANFrame *, int); + private: Ui::FramePlaybackWindow *ui; QList foundID; diff --git a/mainwindow.cpp b/mainwindow.cpp index 72d886a..e928de1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -64,6 +64,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, &MainWindow::sendSerialPort, worker, &SerialWorker::setSerialPort, Qt::QueuedConnection); connect(worker, &SerialWorker::receivedFrame, this, &MainWindow::gotFrame, Qt::QueuedConnection); connect(this, &MainWindow::updateBaudRates, worker, &SerialWorker::updateBaudRates, Qt::QueuedConnection); + connect(this, &MainWindow::sendCANFrame, worker, &SerialWorker::sendFrame, Qt::QueuedConnection); serialWorkerThread.start(); graphingWindow = NULL; @@ -596,12 +597,20 @@ void MainWindow::showGraphingWindow() void MainWindow::showFrameDataAnalysis() { //only create an instance of the object if we dont have one. Otherwise just display the existing one. - if (!frameInfoWindow) frameInfoWindow = new FrameInfoWindow(model->getListReference()); + if (!frameInfoWindow) + { + frameInfoWindow = new FrameInfoWindow(model->getListReference()); + } frameInfoWindow->show(); } void MainWindow::showPlaybackWindow() { - if (!playbackWindow) playbackWindow = new FramePlaybackWindow(model->getListReference()); + if (!playbackWindow) + { + playbackWindow = new FramePlaybackWindow(model->getListReference()); + //connect signal to signal to pass the signal through to whoever is handling the slot + connect(playbackWindow, SIGNAL(sendCANFrame(const CANFrame*,int)), this, SIGNAL(sendCANFrame(const CANFrame*,int))); + } playbackWindow->show(); } diff --git a/mainwindow.h b/mainwindow.h index 1ac3a5a..e6a2467 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -37,6 +37,7 @@ public slots: signals: void sendSerialPort(QString portName); void updateBaudRates(int, int); + void sendCANFrame(const CANFrame *, int); private: Ui::MainWindow *ui; diff --git a/serialworker.cpp b/serialworker.cpp index 7e133a7..975a0f2 100644 --- a/serialworker.cpp +++ b/serialworker.cpp @@ -50,12 +50,14 @@ void SerialWorker::readSerialData() } } -void SerialWorker::sendFrame(CANFrame *frame, int bus = 0) +void SerialWorker::sendFrame(const CANFrame *frame, int bus = 0) { QByteArray buffer; int c; int ID; + qDebug() << "Sending out frame with id " << frame->ID; + ID = frame->ID; if (frame->extended) ID |= 1 << 31; @@ -75,6 +77,7 @@ void SerialWorker::sendFrame(CANFrame *frame, int bus = 0) if (serial == NULL) return; if (!serial->isOpen()) return; + qDebug() << "writing " << buffer.length() << " bytes to serial port"; serial->write(buffer); } diff --git a/serialworker.h b/serialworker.h index 181eef0..b2e6e8d 100644 --- a/serialworker.h +++ b/serialworker.h @@ -34,7 +34,7 @@ private slots: //we receive things in slots public slots: void setSerialPort(QString); - void sendFrame(CANFrame *, int); + void sendFrame(const CANFrame *, int); void updateBaudRates(int, int);