Skip to content

Commit

Permalink
Fixes to CANAlyzer ASC format when saving. Hopefully perfectly matches
Browse files Browse the repository at this point in the history
now
  • Loading branch information
collin80 committed Mar 20, 2019
1 parent a5d7b04 commit 3e4e9ac
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions framefileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,15 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
lineCounter = 0;
}

outFile->write(QString::number((frames->at(c).timestamp - offsetTime) / 1000000.0, 'f', 5).toUtf8());
uint64_t timeStamp = (frames->at(c).timestamp - offsetTime) / 1000000ull;
int tsLen = QString::number(timeStamp).length();
int precision = 6;
//vector seems to keep 10 bytes at the start of the line for the timestamp. It should never exceed this
//and there should never be a precision over 6 digits after the decimal
if (tsLen > 3) precision = 9 - tsLen;
outFile->write(QString::number((frames->at(c).timestamp - offsetTime) / 1000000.0, 'f', precision).rightJustified(10, ' ').toUtf8());
outFile->putChar(' ');
outFile->write(QString::number(frames->at(c).bus).toUtf8());
outFile->write(QString::number(frames->at(c).bus + 1).toUtf8());
outFile->write(" ");
if (frames->at(c).extended)
outFile->write(QString::number(frames->at(c).ID, 16).toUpper().rightJustified(8, '0').toUtf8());
Expand All @@ -822,18 +828,18 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
outFile->write(QString::number(frames->at(c).ID, 16).toUpper().rightJustified(3, '0').toUtf8());
outFile->write(" ");
}
outFile->write(" ");
outFile->write(" ");

if (frames->at(c).isReceived) outFile->write("Rx d ");
else outFile->write("Tx d ");
if (frames->at(c).isReceived) outFile->write("Rx D ");
else outFile->write("Tx D ");

outFile->write(QString::number(frames->at(c).len).toUtf8());
outFile->putChar(' ');
outFile->write(" ");

for (unsigned int temp = 0; temp < frames->at(c).len; temp++)
{
outFile->write(QString::number(frames->at(c).data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
outFile->putChar(' ');
outFile->write(" ");
}

outFile->write("\n");
Expand Down

0 comments on commit 3e4e9ac

Please sign in to comment.