Skip to content

Commit

Permalink
Fix Decoding of Canalzyer ASC files
Browse files Browse the repository at this point in the history
 * Properly decode and encode extended IDs
 * Properly decode and encode RTR messages
  • Loading branch information
schultetwin committed Nov 11, 2019
1 parent 0996fe8 commit 2984351
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions framefileio.cpp
Expand Up @@ -1287,14 +1287,24 @@ bool FrameFileIO::loadCanalyzerASC(QString filename, QVector<CANFrame>* frames)
if (tokens.length() > 5)
{
thisFrame.timestamp = static_cast<uint64_t>(tokens[0].toDouble() * 1000000.0);
thisFrame.ID = tokens[2].toUInt(nullptr, 16);
if (tokens[2].endsWith('x'))
{
QByteArray copied_id = tokens[2];
copied_id.chop(1);
thisFrame.ID = copied_id.toUInt(nullptr, 16);
thisFrame.extended = true;
}
else
{
thisFrame.ID = tokens[2].toUInt(nullptr, 16);
thisFrame.extended = false;
}
thisFrame.len = tokens[5].toInt();
if (thisFrame.len > 8) return false;
if (thisFrame.len < 0) return false;
thisFrame.isReceived = tokens[3].toUpper().contains("RX");
thisFrame.bus = tokens[1].toInt();
thisFrame.extended = (thisFrame.ID > 0x7FF);
thisFrame.remote = false;
thisFrame.remote = tokens[4] == "r";
for (int d = 6; d < (6 + static_cast<int>(thisFrame.len)); d++)
{
if (tokens.count() > d)
Expand Down Expand Up @@ -1365,16 +1375,22 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
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());
outFile->write("x");
}
else
{
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 ");
else outFile->write("Tx ");

if (frames->at(c).remote) outFile->write("r ");
else outFile->write("d ");

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

0 comments on commit 2984351

Please sign in to comment.