From f5b8f1090b44d1831a8a813c106aa4908c4c71d6 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 17 May 2018 20:40:17 -0400 Subject: [PATCH 1/3] Fixes to allow native files and CRTD files to load with frame that have zero data bytes, allow loading of files that have errors. --- framefileio.cpp | 4 ++-- mainwindow.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/framefileio.cpp b/framefileio.cpp index 53fd2e2..9ba521c 100644 --- a/framefileio.cpp +++ b/framefileio.cpp @@ -325,7 +325,7 @@ bool FrameFileIO::loadCRTDFile(QString filename, QVector* frames) { QList tokens = line.split(' '); int multiplier; - if (tokens.length() > 3) + if (tokens.length() > 2) { int idxOfDecimal = tokens[0].indexOf('.'); if (idxOfDecimal > -1) { @@ -699,7 +699,7 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector* frames) if (line.length() > 2) { QList tokens = line.split(','); - if (tokens.length() >= 6) + if (tokens.length() >= 5) { if (tokens[0].length() > 3) { diff --git a/mainwindow.cpp b/mainwindow.cpp index 40df9e7..6752d46 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -545,7 +545,20 @@ void MainWindow::handleLoadFile() QString filename; QVector tempFrames; - if (FrameFileIO::loadFrameFile(filename, &tempFrames)) + QMessageBox::StandardButton confirmDialog; + + bool loadResult = FrameFileIO::loadFrameFile(filename, &tempFrames); + + if (!loadResult) + { + confirmDialog = QMessageBox::question(this, "Error Loading", "Do you want to salvage what could be loaded?", + QMessageBox::Yes|QMessageBox::No); + if (confirmDialog == QMessageBox::Yes) { + loadResult = true; + } + } + + if (loadResult) { ui->canFramesView->scrollToTop(); model->clearFrames(); From f345642b034bb04228225599da30cd77e3875719 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 17 May 2018 20:41:19 -0400 Subject: [PATCH 2/3] Fixes to gvret serial for use with TCP/IP connection --- connections/gvretserial.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index 83a53ec..ff0a1d0 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -72,12 +72,6 @@ void GVRetSerial::sendToSerial(const QByteArray &bytes) void GVRetSerial::piStarted() { connectDevice(); - - /* start timer */ - connect(&mTimer, SIGNAL(timeout()), this, SLOT(handleTick())); - mTimer.setInterval(250); //tick four times per second - mTimer.setSingleShot(false); //keep ticking - mTimer.start(); } @@ -287,12 +281,14 @@ void GVRetSerial::connectDevice() /* open new device */ if (getPort().contains('.')) //TCP/IP mode then since it looks like an IP address { + qDebug() << "TCP Connection to a GVRET device"; tcpClient = new QTcpSocket(); tcpClient->connectToHost(getPort(), 23); connect(tcpClient, SIGNAL(readyRead()), this, SLOT(readSerialData())); connect(tcpClient, SIGNAL(connected()), this, SLOT(tcpConnected())); } else { + qDebug() << "Serial connection to a GVRET device"; serial = new QSerialPort(QSerialPortInfo(getPort())); if(!serial) { qDebug() << "can't open serial port " << getPort(); @@ -362,6 +358,12 @@ void GVRetSerial::tcpConnected() sendToSerial(output); + /* start timer */ + connect(&mTimer, SIGNAL(timeout()), this, SLOT(handleTick())); + mTimer.setInterval(250); //tick four times per second + mTimer.setSingleShot(false); //keep ticking + mTimer.start(); + if(doValidation) { QTimer::singleShot(1000, this, SLOT(connectionTimeout())); } From 31618e87d13c50d27946dbbbd5dc347d663ce034 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 17 May 2018 20:41:42 -0400 Subject: [PATCH 3/3] Fix to loading of online help system. --- helpwindow.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/helpwindow.cpp b/helpwindow.cpp index a07eb5d..5e5c016 100644 --- a/helpwindow.cpp +++ b/helpwindow.cpp @@ -10,7 +10,7 @@ HelpWindow::HelpWindow(QWidget *parent) : { ui->setupUi(this); - m_helpEngine = new QHelpEngineCore("SavvyCAN.qhc", this); + m_helpEngine = new QHelpEngineCore(QApplication::applicationDirPath() +"/SavvyCAN.qhc", this); if (!m_helpEngine->setupData()) { delete m_helpEngine; m_helpEngine = 0; @@ -66,8 +66,10 @@ HelpWindow* HelpWindow::getRef() void HelpWindow::showHelp(QString help) { if (m_helpEngine) { - qDebug() << "Searching for " << help; - QByteArray helpData = m_helpEngine->fileData(QUrl("qthelp://org.sphinx.savvycan.181/doc/" + help)); + QString url = "qthelp://org.sphinx.savvycan.181/doc/" + help; + qDebug() << "Searching for " << url; + QByteArray helpData = m_helpEngine->fileData(QUrl(url)); + qDebug() << "Help file size: " << helpData.length(); ui->textHelp->setText(helpData); } else @@ -78,17 +80,5 @@ void HelpWindow::showHelp(QString help) readSettings(); self->show(); } -/* -QVariant HelpBrowser::loadResource(int type, const QUrl &name) -{ -QByteArray ba; -if (type < 4 && m_helpEngine) { - QUrl url(name); - if (name.isRelative()) - url = source().resolved(url); - ba = m_helpEngine->fileData(url); -} -return ba; -} -*/ +