1247;RX;0xC2;8;0x5C;0x87;0x00;0x00;0x01;0x00;0x00;0x1C 1218;RX;0x236;1;0x00;0x00;0x00;0x00;0x00;0x00;0x00;0xF0 tokens: 0 = timestamp in ms 1 = direction (RX, TX) 2 = ID (in hex with 0x prefix) 3 = data length 4-x = data bytes in hex with 0x prefix */
| 2524 | 4-x = data bytes in hex with 0x prefix |
| 2525 | */ |
| 2526 | bool FrameFileIO::saveMicrochipFile(QString filename, const QVector<CANFrame>* frames) |
| 2527 | { |
| 2528 | QFile *outFile = new QFile(filename); |
| 2529 | QDateTime timestamp, tempStamp; |
| 2530 | int lineCounter = 0; |
| 2531 | |
| 2532 | timestamp = QDateTime::currentDateTime(); |
| 2533 | |
| 2534 | if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text)) |
| 2535 | { |
| 2536 | delete outFile; |
| 2537 | return false; |
| 2538 | } |
| 2539 | |
| 2540 | outFile->write("//---------------------------------\n"); |
| 2541 | outFile->write("Microchip Technology Inc.\n"); |
| 2542 | outFile->write("CAN BUS Analyzer\n"); |
| 2543 | outFile->write("SavvyCAN Exporter\n"); |
| 2544 | outFile->write("Logging Started: "); |
| 2545 | outFile->write(timestamp.toString("d/M/yyyy h:m:s").toUtf8()); |
| 2546 | outFile->write("\n"); |
| 2547 | outFile->write("//---------------------------------\n"); |
| 2548 | |
| 2549 | for (int c = 0; c < frames->count(); c++) |
| 2550 | { |
| 2551 | lineCounter++; |
| 2552 | if (lineCounter > 100) |
| 2553 | { |
| 2554 | qApp->processEvents(); |
| 2555 | lineCounter = 0; |
| 2556 | } |
| 2557 | |
| 2558 | outFile->write(QString::number((int)(frames->at(c).timestamp / 1000)).toUtf8()); |
| 2559 | if (frames->at(c).isReceived) outFile->write(";RX;"); |
| 2560 | else outFile->write(";TX;"); |
| 2561 | outFile->write("0x" + QString::number(frames->at(c).ID, 16).toUpper().rightJustified(8, '0').toUtf8() + ";"); |
| 2562 | outFile->write(QString::number(frames->at(c).len).toUtf8() + ";"); |
| 2563 | |
| 2564 | for (unsigned int temp = 0; temp < frames->at(c).len; temp++) |
| 2565 | { |
| 2566 | outFile->write("0x" + QString::number(frames->at(c).data[temp], 16).toUpper().rightJustified(2, '0').toUtf8()); |
| 2567 | outFile->putChar(';'); |
| 2568 | } |
| 2569 | |
| 2570 | outFile->write("\n"); |
| 2571 | |
| 2572 | } |
| 2573 | outFile->close(); |
| 2574 | delete outFile; |
| 2575 | return true; |
| 2576 | } |
| 2577 | |
| 2578 | bool FrameFileIO::isTraceFile(QString filename) |
| 2579 | { |