The "native" file format for this program Time Stamp,ID,Extended,Dir,Bus,LEN,D1,D2,D3,D4,D5,D6,D7,D8 39747828,000005EB,false,Rx,0,8,E8,45,85,4B,4A,28,36,69,
| 1453 | //Time Stamp,ID,Extended,Dir,Bus,LEN,D1,D2,D3,D4,D5,D6,D7,D8 |
| 1454 | //39747828,000005EB,false,Rx,0,8,E8,45,85,4B,4A,28,36,69, |
| 1455 | bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames) |
| 1456 | { |
| 1457 | QFile *inFile = new QFile(filename); |
| 1458 | CANFrame thisFrame; |
| 1459 | QByteArray line; |
| 1460 | int fileVersion = 1; |
| 1461 | long long timeStamp = Utility::GetTimeMS(); |
| 1462 | int lineCounter = 0; |
| 1463 | bool foundErrors = false; |
| 1464 | thisFrame.remote = false; |
| 1465 | |
| 1466 | if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text)) |
| 1467 | { |
| 1468 | delete inFile; |
| 1469 | return false; |
| 1470 | } |
| 1471 | |
| 1472 | line = inFile->readLine().toUpper(); //read out the header first and discard it. |
| 1473 | if (line.at(23) == 'D') fileVersion = 2; //Dir is found starting at position 23 if this is a V2 file |
| 1474 | |
| 1475 | while (!inFile->atEnd()) { |
| 1476 | lineCounter++; |
| 1477 | if (lineCounter > 100) |
| 1478 | { |
| 1479 | qApp->processEvents(); |
| 1480 | lineCounter = 0; |
| 1481 | } |
| 1482 | |
| 1483 | line = inFile->readLine().simplified(); |
| 1484 | if (line.length() > 2) |
| 1485 | { |
| 1486 | QList<QByteArray> tokens = line.split(','); |
| 1487 | if (tokens.length() >= 5) |
| 1488 | { |
| 1489 | if (tokens[0].length() > 3) |
| 1490 | { |
| 1491 | long long temp = tokens[0].toLongLong(); |
| 1492 | thisFrame.timestamp = temp; |
| 1493 | } |
| 1494 | else |
| 1495 | { |
| 1496 | timeStamp += 5; |
| 1497 | thisFrame.timestamp = timeStamp; |
| 1498 | } |
| 1499 | |
| 1500 | thisFrame.ID = tokens[1].toInt(nullptr, 16); |
| 1501 | if (tokens[2].toUpper().contains("TRUE")) thisFrame.extended = 1; |
| 1502 | else thisFrame.extended = 0; |
| 1503 | |
| 1504 | thisFrame.remote = false; |
| 1505 | |
| 1506 | if (fileVersion == 1) |
| 1507 | { |
| 1508 | thisFrame.isReceived = true; |
| 1509 | thisFrame.bus = tokens[3].toInt(); |
| 1510 | thisFrame.len = tokens[4].toUInt(); |
| 1511 | if (thisFrame.len > 8) thisFrame.len = 8; |
| 1512 | for (int c = 0; c < 8; c++) thisFrame.data[c] = 0; |