MCPcopy Create free account
hub / github.com/collin80/SavvyCAN / loadCANOpenFile

Method loadCANOpenFile

framefileio.cpp:852–911  ·  view source on GitHub ↗

"Message Number","Time (ms)","Time","Excel Time","Count","ID","Flags","Message Type","Node","Details","Process Data","Data (Hex)","Data (Text)","Data (Decimal)","Length","Raw Message" "0","0.000","8:09:42:48.7953090'",43447.7100146116,"","0x2E1","","Default: PDO","","Default: TPDO 2 of Node 0x61 (97)","","10 21 04 00 00 00 00 00 ",". ! . . . . . . ","U:0 S:0","8","10 21 04 00 00 00 00 00"

Source from the content-addressed store, hash-verified

850//"Message Number","Time (ms)","Time","Excel Time","Count","ID","Flags","Message Type","Node","Details","Process Data","Data (Hex)","Data (Text)","Data (Decimal)","Length","Raw Message"
851//"0","0.000","8:09:42:48.7953090'",43447.7100146116,"","0x2E1","","Default: PDO","","Default: TPDO 2 of Node 0x61 (97)","","10 21 04 00 00 00 00 00 ",". ! . . . . . . ","U:0 S:0","8","10 21 04 00 00 00 00 00"
852bool FrameFileIO::loadCANOpenFile(QString filename, QVector<CANFrame>* frames)
853{
854 QFile *inFile = new QFile(filename);
855 CANFrame thisFrame;
856 QByteArray line;
857 int lineCounter = 0;
858 bool foundErrors = false;
859
860 if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
861 {
862 delete inFile;
863 qDebug() << "Could not open the file!";
864 return false;
865 }
866
867 line = inFile->readLine(); //read out the header first and discard it.
868 line = inFile->readLine();
869 line = inFile->readLine();
870 line = inFile->readLine();
871 line = inFile->readLine();
872
873 while (!inFile->atEnd()) {
874 lineCounter++;
875 if (lineCounter > 100)
876 {
877 qApp->processEvents();
878 lineCounter = 0;
879 }
880
881 line = inFile->readLine().replace('\"', ' ').simplified();
882 if (line.length() > 2)
883 {
884 QList<QByteArray> tokens = line.split(',');
885 if (tokens.length() > 11)
886 {
887 thisFrame.timestamp = (int64_t)(tokens[1].simplified().toDouble() * 1000.0);
888 thisFrame.ID = Utility::ParseStringToNum(tokens[5].simplified());
889 thisFrame.extended = (thisFrame.ID > 0x7FF);
890 thisFrame.isReceived = true;
891 thisFrame.remote = false;
892 thisFrame.bus = 0;
893 QList<QByteArray> dataTok = tokens[11].simplified().split(' ');
894 thisFrame.len = dataTok.length();
895 for (unsigned int d = 0; d < thisFrame.len; d++)
896 {
897 if (dataTok[d] != "")
898 {
899 thisFrame.data[d] = dataTok[d].simplified().toInt(nullptr, 16);
900 }
901 else thisFrame.data[d] = 0;
902 }
903 frames->append(thisFrame);
904 }
905 else foundErrors = true;
906 }
907 }
908 inFile->close();
909 delete inFile;

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected