From afc4707575ad9d123e0221d593d6444eb5a51fe5 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sat, 13 Jun 2015 20:23:58 -0400 Subject: [PATCH] Temporary commit to make savvy can work with older GVRET versions. --- flowviewwindow.h | 2 +- frameplaybackwindow.cpp | 10 +++++++++- frameplaybackwindow.h | 4 +++- mainwindow.cpp | 9 ++++++--- mainwindow.h | 1 + serialworker.cpp | 14 +++++++------- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/flowviewwindow.h b/flowviewwindow.h index 7cb7cf2..20fb280 100644 --- a/flowviewwindow.h +++ b/flowviewwindow.h @@ -28,7 +28,7 @@ private slots: void changeLooping(bool check); void timerTriggered(); void changeID(QString); - void updatedFrames(int); + void updatedFrames(int); private: Ui::FlowViewWindow *ui; diff --git a/frameplaybackwindow.cpp b/frameplaybackwindow.cpp index 5405487..8b04626 100644 --- a/frameplaybackwindow.cpp +++ b/frameplaybackwindow.cpp @@ -2,13 +2,14 @@ #include "ui_frameplaybackwindow.h" #include -FramePlaybackWindow::FramePlaybackWindow(QVector *frames, QWidget *parent) : +FramePlaybackWindow::FramePlaybackWindow(QVector *frames, SerialWorker *worker, QWidget *parent) : QDialog(parent), ui(new Ui::FramePlaybackWindow) { ui->setupUi(this); modelFrames = frames; + serialWorker = worker; playbackTimer = new QTimer(); @@ -43,6 +44,8 @@ FramePlaybackWindow::FramePlaybackWindow(QVector *frames, QWidget *par playbackTimer->setInterval(ui->spinPlaySpeed->value()); //set the timer to the default value of the control + connect(this, SIGNAL(sendCANFrame(const CANFrame*,int)), worker, SLOT(sendFrame(const CANFrame*,int)), Qt::QueuedConnection); + } FramePlaybackWindow::~FramePlaybackWindow() @@ -197,6 +200,7 @@ void FramePlaybackWindow::updatePosition(bool forward) } //only send frame out if its ID is checked in the list. Otherwise discard it. + QList idList = ui->listID->findItems(QString::number(modelFrames->at(currentPosition).ID, 16).toUpper().rightJustified(4,'0'), Qt::MatchExactly); if (idList.count() > 0) { @@ -207,7 +211,11 @@ void FramePlaybackWindow::updatePosition(bool forward) if (whichBusSend & 1) emit sendCANFrame(thisFrame, 0); if (whichBusSend & 2) emit sendCANFrame(thisFrame, 1); if (whichBusSend & 4) emit sendCANFrame(thisFrame, thisFrame->bus); + //if (whichBusSend & 1) serialWorker->sendFrame(thisFrame, 0); + //if (whichBusSend & 2) serialWorker->sendFrame(thisFrame, 1); + //if (whichBusSend & 4) serialWorker->sendFrame(thisFrame, thisFrame->bus); updateFrameLabel(); } } + } diff --git a/frameplaybackwindow.h b/frameplaybackwindow.h index d962457..a91bb38 100644 --- a/frameplaybackwindow.h +++ b/frameplaybackwindow.h @@ -5,6 +5,7 @@ #include #include #include "can_structs.h" +#include "serialworker.h" namespace Ui { class FramePlaybackWindow; @@ -15,7 +16,7 @@ class FramePlaybackWindow : public QDialog Q_OBJECT public: - explicit FramePlaybackWindow(QVector *frames, QWidget *parent = 0); + explicit FramePlaybackWindow(QVector *frames, SerialWorker *worker, QWidget *parent = 0); ~FramePlaybackWindow(); private slots: @@ -43,6 +44,7 @@ private: QVector *modelFrames; int currentPosition; QTimer *playbackTimer; + SerialWorker *serialWorker; bool playbackActive; bool playbackForward; int whichBusSend; diff --git a/mainwindow.cpp b/mainwindow.cpp index 6d91038..73bac45 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -26,6 +26,8 @@ Things currently broken or in need of attention: 2. Some of the save formats are not actually implemented and silently fail. 3. It would be nice to be able to save the graphing view in the flow view. 4. It would also be nice to be able to save an image of the bitfield grid too. +5. New GVRET firmware has a hard time sending data (6 frames per second!) +6. If you load a file, use detailed view, clear it, load another, it seems to only show new IDs */ QString MainWindow::loadedFileName = ""; @@ -83,7 +85,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->cbSpeed2->addItem(tr("1000000")); ui->cbSpeed2->addItem(tr("33333")); - SerialWorker *worker = new SerialWorker(model); + worker = new SerialWorker(model); worker->moveToThread(&serialWorkerThread); connect(&serialWorkerThread, &QThread::finished, worker, &QObject::deleteLater); connect(this, &MainWindow::sendSerialPort, worker, &SerialWorker::setSerialPort, Qt::QueuedConnection); @@ -97,6 +99,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, &MainWindow::startFrameCapturing, worker, &SerialWorker::startFrameCapture); connect(this, &MainWindow::stopFrameCapturing, worker, &SerialWorker::stopFrameCapture); serialWorkerThread.start(); + serialWorkerThread.setPriority(QThread::TimeCriticalPriority); graphingWindow = NULL; frameInfoWindow = NULL; @@ -994,9 +997,9 @@ void MainWindow::showPlaybackWindow() { if (!playbackWindow) { - playbackWindow = new FramePlaybackWindow(model->getListReference()); + playbackWindow = new FramePlaybackWindow(model->getListReference(), worker); //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))); + //connect(playbackWindow, SIGNAL(sendCANFrame(const CANFrame*,int)), this, SIGNAL(sendCANFrame(const CANFrame*,int))); } playbackWindow->show(); } diff --git a/mainwindow.h b/mainwindow.h index 341a101..e117b97 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -81,6 +81,7 @@ private: DBCHandler *dbcHandler; QList ports; QThread serialWorkerThread; + SerialWorker *worker; QByteArray inputBuffer; bool allowCapture; bool bDirty; //have frames been added or subtracted since the last save/load? diff --git a/serialworker.cpp b/serialworker.cpp index 612831c..55a5972 100644 --- a/serialworker.cpp +++ b/serialworker.cpp @@ -64,7 +64,7 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port) output.append(0xF1); //another command to the GVRET output.append(0x07); //request device information serial->write(output); - connected = false; + connected = true; //should be false. only set true to test old firmware connect(serial, SIGNAL(readyRead()), this, SLOT(readSerialData())); QTimer::singleShot(1000, this, SLOT(connectionTimeout())); if (ticker == NULL) @@ -88,9 +88,9 @@ void SerialWorker::connectionTimeout() if (!connected) //no? { //then emit the the failure signal and see if anyone cares - qDebug() << "Failed to connect to GVRET at that com port"; - ticker->stop(); - emit connectionFailure(); + //qDebug() << "Failed to connect to GVRET at that com port"; + //ticker->stop(); + //emit connectionFailure(); } } @@ -112,10 +112,10 @@ void SerialWorker::sendFrame(const CANFrame *frame, int bus = 0) int c; int ID; - if (!connected) return; - //qDebug() << "Sending out frame with id " << frame->ID; + if (!connected) return; + ID = frame->ID; if (frame->extended) ID |= 1 << 31; @@ -135,7 +135,7 @@ void SerialWorker::sendFrame(const CANFrame *frame, int bus = 0) if (serial == NULL) return; if (!serial->isOpen()) return; - qDebug() << "writing " << buffer.length() << " bytes to serial port"; + //qDebug() << "writing " << buffer.length() << " bytes to serial port"; serial->write(buffer); }