Added PCAN files for loading (but not saving)
This commit is contained in:
@@ -126,6 +126,7 @@ bool FrameFileIO::loadFrameFile(QString &fileName, QVector<CANFrame>* frameCache
|
|||||||
filters.append(QString(tr("CAN-DO Log (*.avc *.can *.evc *.qcc *.AVC *.CAN *.EVC *.QCC)")));
|
filters.append(QString(tr("CAN-DO Log (*.avc *.can *.evc *.qcc *.AVC *.CAN *.EVC *.QCC)")));
|
||||||
filters.append(QString(tr("Vehicle Spy (*.csv *.CSV)")));
|
filters.append(QString(tr("Vehicle Spy (*.csv *.CSV)")));
|
||||||
filters.append(QString(tr("Candump/Kayak (*.log *.LOG)")));
|
filters.append(QString(tr("Candump/Kayak (*.log *.LOG)")));
|
||||||
|
filters.append(QString(tr("PCAN Viewer (*.txt *.TXT)")));
|
||||||
|
|
||||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
dialog.setNameFilters(filters);
|
dialog.setNameFilters(filters);
|
||||||
@@ -155,6 +156,7 @@ bool FrameFileIO::loadFrameFile(QString &fileName, QVector<CANFrame>* frameCache
|
|||||||
if (dialog.selectedNameFilter() == filters[7]) result = loadCANDOFile(filename, frameCache);
|
if (dialog.selectedNameFilter() == filters[7]) result = loadCANDOFile(filename, frameCache);
|
||||||
if (dialog.selectedNameFilter() == filters[8]) result = loadVehicleSpyFile(filename, frameCache);
|
if (dialog.selectedNameFilter() == filters[8]) result = loadVehicleSpyFile(filename, frameCache);
|
||||||
if (dialog.selectedNameFilter() == filters[9]) result = loadCanDumpFile(filename, frameCache);
|
if (dialog.selectedNameFilter() == filters[9]) result = loadCanDumpFile(filename, frameCache);
|
||||||
|
if (dialog.selectedNameFilter() == filters[10]) result = loadPCANFile(filename, frameCache);
|
||||||
|
|
||||||
progress.cancel();
|
progress.cancel();
|
||||||
|
|
||||||
@@ -393,6 +395,70 @@ bool FrameFileIO::saveCRTDFile(QString filename, const QVector<CANFrame>* frames
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//; Message Number
|
||||||
|
//; | Time Offset (ms)
|
||||||
|
//; | | Type
|
||||||
|
//; | | | ID (hex)
|
||||||
|
//; | | | | Data Length Code
|
||||||
|
//; | | | | | Data Bytes (hex) ...
|
||||||
|
//; | | | | | |
|
||||||
|
//;---+-- ----+---- --+-- ----+--- + -+ -- -- -- -- -- -- --
|
||||||
|
// 0-6 10-18 21-25 28-35 38 41-?
|
||||||
|
//Fixed length lines
|
||||||
|
bool FrameFileIO::loadPCANFile(QString filename, QVector<CANFrame>* frames)
|
||||||
|
{
|
||||||
|
QFile *inFile = new QFile(filename);
|
||||||
|
CANFrame thisFrame;
|
||||||
|
QByteArray line;
|
||||||
|
int lineCounter = 0;
|
||||||
|
bool foundErrors = false;
|
||||||
|
|
||||||
|
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
delete inFile;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!inFile->atEnd()) {
|
||||||
|
lineCounter++;
|
||||||
|
if (lineCounter > 100)
|
||||||
|
{
|
||||||
|
qApp->processEvents();
|
||||||
|
lineCounter = 0;
|
||||||
|
}
|
||||||
|
line = inFile->readLine();
|
||||||
|
if (line.startsWith(';')) continue;
|
||||||
|
if (line.length() > 2)
|
||||||
|
{
|
||||||
|
thisFrame.timestamp = line.mid(10, 8).simplified().toFloat() * 1000ull;
|
||||||
|
thisFrame.ID = line.mid(28, 8).simplified().toUInt(NULL, 16);
|
||||||
|
if (thisFrame.ID < 0x1FFFFFFF)
|
||||||
|
{
|
||||||
|
thisFrame.len = line.mid(38,1).toInt();
|
||||||
|
thisFrame.isReceived = true;
|
||||||
|
thisFrame.bus = 0;
|
||||||
|
thisFrame.extended = false;
|
||||||
|
QList<QByteArray> tokens = line.mid(41, thisFrame.len * 3).split(' ');
|
||||||
|
for (int d = 0; d < thisFrame.len; d++)
|
||||||
|
{
|
||||||
|
if (tokens[d] != "")
|
||||||
|
{
|
||||||
|
thisFrame.data[d] = tokens[d].toInt(NULL, 16);
|
||||||
|
}
|
||||||
|
else thisFrame.data[d] = 0;
|
||||||
|
}
|
||||||
|
frames->append(thisFrame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else foundErrors = true;
|
||||||
|
}
|
||||||
|
inFile->close();
|
||||||
|
delete inFile;
|
||||||
|
return !foundErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//The "native" file format for this program
|
//The "native" file format for this program
|
||||||
bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
static bool loadFrameFile(QString &, QVector<CANFrame>*);
|
static bool loadFrameFile(QString &, QVector<CANFrame>*);
|
||||||
static bool saveFrameFile(QString &, const QVector<CANFrame>*);
|
static bool saveFrameFile(QString &, const QVector<CANFrame>*);
|
||||||
static bool loadCanDumpFile(QString, QVector<CANFrame>*);
|
static bool loadCanDumpFile(QString, QVector<CANFrame>*);
|
||||||
|
static bool loadPCANFile(QString, QVector<CANFrame>*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString unQuote(QString);
|
static QString unQuote(QString);
|
||||||
|
|||||||
Reference in New Issue
Block a user