Added a bit of error handling to file loading routines. It will now most likely
tell you that you picked the wrong format instead of crashing. Updated version number to match new functionality.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CONFIG
|
#ifndef CONFIG
|
||||||
#define CONFIG
|
#define CONFIG
|
||||||
|
|
||||||
#define VERSION 152
|
#define VERSION 154
|
||||||
|
|
||||||
//try to keep this in sync.
|
//try to keep this in sync.
|
||||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||||
|
|||||||
+93
-18
@@ -1,5 +1,6 @@
|
|||||||
#include "framefileio.h"
|
#include "framefileio.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
|
|
||||||
FrameFileIO::FrameFileIO()
|
FrameFileIO::FrameFileIO()
|
||||||
@@ -159,7 +160,13 @@ bool FrameFileIO::loadFrameFile(QString &fileName, QVector<CANFrame>* frameCache
|
|||||||
fileName = fileList[fileList.length() - 1];
|
fileName = fileList[fileList.length() - 1];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else return false;
|
else
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText("File load completed with errors.\r\nPerhaps you selected the wrong file type?");
|
||||||
|
msgBox.exec();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -175,6 +182,7 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
|
|||||||
QByteArray line;
|
QByteArray line;
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
bool pastHeader = false;
|
bool pastHeader = false;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -189,6 +197,8 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
|
|||||||
if (lineCounter == 2) pastHeader = true;
|
if (lineCounter == 2) pastHeader = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inFile->atEnd()) foundErrors = true;
|
||||||
|
|
||||||
while (!inFile->atEnd()) {
|
while (!inFile->atEnd()) {
|
||||||
lineCounter++;
|
lineCounter++;
|
||||||
if (lineCounter > 100)
|
if (lineCounter > 100)
|
||||||
@@ -199,6 +209,8 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
|
|||||||
line = inFile->readLine().simplified().toUpper();
|
line = inFile->readLine().simplified().toUpper();
|
||||||
|
|
||||||
QList<QByteArray> tokens = line.split(',');
|
QList<QByteArray> tokens = line.split(',');
|
||||||
|
if (tokens.length() > 20)
|
||||||
|
{
|
||||||
thisFrame.bus = 0;
|
thisFrame.bus = 0;
|
||||||
thisFrame.timestamp = tokens[1].toDouble() * 1000000.0;
|
thisFrame.timestamp = tokens[1].toDouble() * 1000000.0;
|
||||||
if (tokens[5].startsWith("T")) thisFrame.isReceived = false;
|
if (tokens[5].startsWith("T")) thisFrame.isReceived = false;
|
||||||
@@ -217,12 +229,13 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
|
|||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameFileIO::saveVehicleSpyFile(QString filename, const QVector<CANFrame> *frames)
|
bool FrameFileIO::saveVehicleSpyFile(QString filename, const QVector<CANFrame> *frames)
|
||||||
@@ -258,6 +271,7 @@ bool FrameFileIO::loadCRTDFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
CANFrame thisFrame;
|
CANFrame thisFrame;
|
||||||
QByteArray line;
|
QByteArray line;
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -279,6 +293,8 @@ bool FrameFileIO::loadCRTDFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
{
|
{
|
||||||
QList<QByteArray> tokens = line.split(' ');
|
QList<QByteArray> tokens = line.split(' ');
|
||||||
int multiplier;
|
int multiplier;
|
||||||
|
if (tokens.length() > 3)
|
||||||
|
{
|
||||||
int idxOfDecimal = tokens[0].indexOf('.');
|
int idxOfDecimal = tokens[0].indexOf('.');
|
||||||
if (idxOfDecimal > -1) {
|
if (idxOfDecimal > -1) {
|
||||||
//int decimalPlaces = tokens[0].length() - tokens[0].indexOf('.') - 1;
|
//int decimalPlaces = tokens[0].length() - tokens[0].indexOf('.') - 1;
|
||||||
@@ -313,10 +329,12 @@ bool FrameFileIO::loadCRTDFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameFileIO::saveCRTDFile(QString filename, const QVector<CANFrame>* frames)
|
bool FrameFileIO::saveCRTDFile(QString filename, const QVector<CANFrame>* frames)
|
||||||
@@ -380,6 +398,7 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
int fileVersion = 1;
|
int fileVersion = 1;
|
||||||
long long timeStamp = Utility::GetTimeMS();
|
long long timeStamp = Utility::GetTimeMS();
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -402,6 +421,8 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
if (line.length() > 2)
|
if (line.length() > 2)
|
||||||
{
|
{
|
||||||
QList<QByteArray> tokens = line.split(',');
|
QList<QByteArray> tokens = line.split(',');
|
||||||
|
if (tokens.length() >= 6)
|
||||||
|
{
|
||||||
if (tokens[0].length() > 3)
|
if (tokens[0].length() > 3)
|
||||||
{
|
{
|
||||||
long long temp = tokens[0].right(10).toLongLong();
|
long long temp = tokens[0].right(10).toLongLong();
|
||||||
@@ -432,6 +453,7 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
else thisFrame.isReceived = false;
|
else thisFrame.isReceived = false;
|
||||||
thisFrame.bus = tokens[4].toInt();
|
thisFrame.bus = tokens[4].toInt();
|
||||||
thisFrame.len = tokens[5].toInt();
|
thisFrame.len = tokens[5].toInt();
|
||||||
|
if (thisFrame.len + 6 > tokens.length()) thisFrame.len = tokens.length() - 6;
|
||||||
for (int c = 0; c < 8; c++) thisFrame.data[c] = 0;
|
for (int c = 0; c < 8; c++) thisFrame.data[c] = 0;
|
||||||
for (int d = 0; d < thisFrame.len; d++)
|
for (int d = 0; d < thisFrame.len; d++)
|
||||||
thisFrame.data[d] = tokens[6 + d].toInt(NULL, 16);
|
thisFrame.data[d] = tokens[6 + d].toInt(NULL, 16);
|
||||||
@@ -439,10 +461,12 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
|
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameFileIO::saveNativeCSVFile(QString filename, const QVector<CANFrame>* frames)
|
bool FrameFileIO::saveNativeCSVFile(QString filename, const QVector<CANFrame>* frames)
|
||||||
@@ -510,6 +534,7 @@ bool FrameFileIO::loadGenericCSVFile(QString filename, QVector<CANFrame>* frames
|
|||||||
QByteArray line;
|
QByteArray line;
|
||||||
long long timeStamp = Utility::GetTimeMS();
|
long long timeStamp = Utility::GetTimeMS();
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -545,10 +570,11 @@ bool FrameFileIO::loadGenericCSVFile(QString filename, QVector<CANFrame>* frames
|
|||||||
|
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
}
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
//4f5,ff 34 23 45 24 e4
|
//4f5,ff 34 23 45 24 e4
|
||||||
@@ -631,6 +657,7 @@ bool FrameFileIO::loadLogFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
QByteArray line;
|
QByteArray line;
|
||||||
uint64_t timeStamp = Utility::GetTimeMS();
|
uint64_t timeStamp = Utility::GetTimeMS();
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -653,6 +680,8 @@ bool FrameFileIO::loadLogFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
if (line.length() > 1)
|
if (line.length() > 1)
|
||||||
{
|
{
|
||||||
QList<QByteArray> tokens = line.split(' ');
|
QList<QByteArray> tokens = line.split(' ');
|
||||||
|
if (tokens.length() >= 6)
|
||||||
|
{
|
||||||
QList<QByteArray> timeToks = tokens[0].split(':');
|
QList<QByteArray> timeToks = tokens[0].split(':');
|
||||||
timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul))
|
timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul))
|
||||||
+ (timeToks[2].toInt() * (1000ul * 1000ul)) + (timeToks[3].toInt() * 100ul);
|
+ (timeToks[2].toInt() * (1000ul * 1000ul)) + (timeToks[3].toInt() * 100ul);
|
||||||
@@ -664,13 +693,17 @@ bool FrameFileIO::loadLogFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
else thisFrame.extended = true;
|
else thisFrame.extended = true;
|
||||||
thisFrame.bus = tokens[2].toInt() - 1;
|
thisFrame.bus = tokens[2].toInt() - 1;
|
||||||
thisFrame.len = tokens[5].toInt();
|
thisFrame.len = tokens[5].toInt();
|
||||||
|
if (thisFrame.len > 8) thisFrame.len = 8;
|
||||||
|
if (thisFrame.len < 0) thisFrame.len = 0;
|
||||||
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = tokens[d + 6].toInt(NULL, 16);
|
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = tokens[d + 6].toInt(NULL, 16);
|
||||||
}
|
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
|
bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
|
||||||
@@ -744,6 +777,7 @@ bool FrameFileIO::loadIXXATFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
QByteArray line;
|
QByteArray line;
|
||||||
uint64_t timeStamp = Utility::GetTimeMS();
|
uint64_t timeStamp = Utility::GetTimeMS();
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -765,14 +799,33 @@ bool FrameFileIO::loadIXXATFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
if (line.length() > 1)
|
if (line.length() > 1)
|
||||||
{
|
{
|
||||||
QList<QByteArray> tokens = line.split(',');
|
QList<QByteArray> tokens = line.split(',');
|
||||||
|
if (line.length() >= 5)
|
||||||
|
{
|
||||||
QString timePortion = unQuote(tokens[0]);
|
QString timePortion = unQuote(tokens[0]);
|
||||||
QStringList timeToks = timePortion.split(':');
|
QStringList timeToks = timePortion.split(':');
|
||||||
|
if (timeToks.length() >= 3)
|
||||||
|
{
|
||||||
timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul))
|
timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul))
|
||||||
+ (timeToks[2].toDouble() * (1000.0 * 1000.0));
|
+ (timeToks[2].toDouble() * (1000.0 * 1000.0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeStamp = 0;
|
||||||
|
foundErrors = true;
|
||||||
|
}
|
||||||
thisFrame.timestamp = timeStamp;
|
thisFrame.timestamp = timeStamp;
|
||||||
thisFrame.ID = unQuote(tokens[1]).toInt(NULL, 16);
|
thisFrame.ID = unQuote(tokens[1]).toInt(NULL, 16);
|
||||||
if (unQuote(tokens[2]).toUpper().at(0) == 'S') thisFrame.extended = false;
|
QString tempStr = unQuote(tokens[2]).toUpper();
|
||||||
|
if (tempStr.length() > 0)
|
||||||
|
{
|
||||||
|
if (tempStr.at(0) == 'S') thisFrame.extended = false;
|
||||||
else thisFrame.extended = true;
|
else thisFrame.extended = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thisFrame.extended = false;
|
||||||
|
foundErrors = true;
|
||||||
|
}
|
||||||
|
|
||||||
thisFrame.isReceived = true;
|
thisFrame.isReceived = true;
|
||||||
thisFrame.bus = 0;
|
thisFrame.bus = 0;
|
||||||
@@ -780,12 +833,14 @@ bool FrameFileIO::loadIXXATFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
QStringList dataToks = unQuote(tokens[4]).simplified().split(' ');
|
QStringList dataToks = unQuote(tokens[4]).simplified().split(' ');
|
||||||
thisFrame.len = dataToks.length();
|
thisFrame.len = dataToks.length();
|
||||||
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = dataToks[d].toInt(NULL, 16);
|
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = dataToks[d].toInt(NULL, 16);
|
||||||
}
|
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frames)
|
bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frames)
|
||||||
@@ -852,6 +907,7 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
QByteArray data;
|
QByteArray data;
|
||||||
int timeOffset = 0;
|
int timeOffset = 0;
|
||||||
uint64_t lastTimeStamp = 0;
|
uint64_t lastTimeStamp = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly))
|
if (!inFile->open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
@@ -887,7 +943,7 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
timeOffset += 60000000ul;
|
timeOffset += 60000000ul;
|
||||||
}
|
}
|
||||||
lastTimeStamp = thisFrame.timestamp;
|
lastTimeStamp = thisFrame.timestamp;
|
||||||
thisFrame.ID = ((unsigned char)data[3] * 256 + (unsigned char)data[2]) & 0x7FF;
|
thisFrame.ID = (((unsigned char)data[3] & 0x0F) * 256 + (unsigned char)data[2]) & 0x7FF;
|
||||||
thisFrame.len = (unsigned char)data[3] >> 4;
|
thisFrame.len = (unsigned char)data[3] >> 4;
|
||||||
|
|
||||||
if (thisFrame.len <= 8 && thisFrame.ID <= 0x7FF)
|
if (thisFrame.len <= 8 && thisFrame.ID <= 0x7FF)
|
||||||
@@ -895,11 +951,12 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = (unsigned char)data[4 + d];
|
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = (unsigned char)data[4 + d];
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameFileIO::saveCANDOFile(QString filename, const QVector<CANFrame>* frames)
|
bool FrameFileIO::saveCANDOFile(QString filename, const QVector<CANFrame>* frames)
|
||||||
@@ -973,6 +1030,7 @@ bool FrameFileIO::loadMicrochipFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
bool inComment = false;
|
bool inComment = false;
|
||||||
long long timeStamp;
|
long long timeStamp;
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -1002,6 +1060,8 @@ bool FrameFileIO::loadMicrochipFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
if (!inComment)
|
if (!inComment)
|
||||||
{
|
{
|
||||||
QList<QByteArray> tokens = line.split(';');
|
QList<QByteArray> tokens = line.split(';');
|
||||||
|
if (tokens.length() >= 4)
|
||||||
|
{
|
||||||
timeStamp = tokens[0].toInt() * 1000;
|
timeStamp = tokens[0].toInt() * 1000;
|
||||||
thisFrame.timestamp = timeStamp;
|
thisFrame.timestamp = timeStamp;
|
||||||
if (tokens[1].at(0) == 'R') thisFrame.isReceived = true;
|
if (tokens[1].at(0) == 'R') thisFrame.isReceived = true;
|
||||||
@@ -1011,15 +1071,20 @@ bool FrameFileIO::loadMicrochipFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
else thisFrame.extended = true;
|
else thisFrame.extended = true;
|
||||||
thisFrame.bus = 0;
|
thisFrame.bus = 0;
|
||||||
thisFrame.len = tokens[3].toInt();
|
thisFrame.len = tokens[3].toInt();
|
||||||
|
if (thisFrame.len > 8) thisFrame.len = 8;
|
||||||
|
if (thisFrame.len < 0) thisFrame.len = 0;
|
||||||
|
if (thisFrame.len + 4 > tokens.length()) thisFrame.len = tokens.length() - 4;
|
||||||
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = (unsigned char)Utility::ParseStringToNum(tokens[4 + d]);
|
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = (unsigned char)Utility::ParseStringToNum(tokens[4 + d]);
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1122,6 +1187,7 @@ bool FrameFileIO::loadTraceFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
QByteArray line;
|
QByteArray line;
|
||||||
long long timeStamp = 0;
|
long long timeStamp = 0;
|
||||||
int lineCounter = 0;
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
@@ -1148,7 +1214,8 @@ bool FrameFileIO::loadTraceFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QList<QByteArray> tokens = line.split('\t');
|
QList<QByteArray> tokens = line.split('\t');
|
||||||
|
if (tokens.length() > 3)
|
||||||
|
{
|
||||||
QList<QByteArray> timestampToks = tokens[1].split(':');
|
QList<QByteArray> timestampToks = tokens[1].split(':');
|
||||||
|
|
||||||
timeStamp = timestampToks[0].toInt() * 1000000ul * 60 * 60;
|
timeStamp = timestampToks[0].toInt() * 1000000ul * 60 * 60;
|
||||||
@@ -1163,16 +1230,20 @@ bool FrameFileIO::loadTraceFile(QString filename, QVector<CANFrame>* frames)
|
|||||||
else thisFrame.extended = true;
|
else thisFrame.extended = true;
|
||||||
thisFrame.bus = 0;
|
thisFrame.bus = 0;
|
||||||
thisFrame.len = tokens[3].toInt();
|
thisFrame.len = tokens[3].toInt();
|
||||||
|
if (thisFrame.len < 0) thisFrame.len = 0;
|
||||||
|
if (thisFrame.len > 8) thisFrame.len = 8;
|
||||||
QList<QByteArray> dataToks = tokens[4].split(' ');
|
QList<QByteArray> dataToks = tokens[4].split(' ');
|
||||||
|
if (thisFrame.len > dataToks.length()) thisFrame.len = dataToks.length();
|
||||||
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = (unsigned char)dataToks[d].toInt(NULL, 16);
|
for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = (unsigned char)dataToks[d].toInt(NULL, 16);
|
||||||
frames->append(thisFrame);
|
frames->append(thisFrame);
|
||||||
}
|
}
|
||||||
|
else foundErrors = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
delete inFile;
|
delete inFile;
|
||||||
return true;
|
return !foundErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameFileIO::saveTraceFile(QString filename, const QVector<CANFrame> * frames)
|
bool FrameFileIO::saveTraceFile(QString filename, const QVector<CANFrame> * frames)
|
||||||
@@ -1266,5 +1337,9 @@ bool FrameFileIO::saveTraceFile(QString filename, const QVector<CANFrame> * fram
|
|||||||
|
|
||||||
QString FrameFileIO::unQuote(QString inStr)
|
QString FrameFileIO::unQuote(QString inStr)
|
||||||
{
|
{
|
||||||
return inStr.split('\"')[1];
|
QStringList temp;
|
||||||
|
temp = inStr.split('\"');
|
||||||
|
if (temp.length() >= 3)
|
||||||
|
return temp[1];
|
||||||
|
return QString("");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user