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

Method loadGenericCSVFile

framefileio.cpp:1737–1787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1735}
1736
1737bool FrameFileIO::loadGenericCSVFile(QString filename, QVector<CANFrame>* frames)
1738{
1739 QFile *inFile = new QFile(filename);
1740 CANFrame thisFrame;
1741 QByteArray line;
1742 long long timeStamp = Utility::GetTimeMS();
1743 int lineCounter = 0;
1744 bool foundErrors = false;
1745 thisFrame.remote = false;
1746
1747 if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
1748 {
1749 delete inFile;
1750 return false;
1751 }
1752
1753 line = inFile->readLine(); //read out the header first and discard it.
1754
1755 while (!inFile->atEnd()) {
1756 lineCounter++;
1757 if (lineCounter > 100)
1758 {
1759 qApp->processEvents();
1760 lineCounter = 0;
1761 }
1762
1763 line = inFile->readLine();
1764 if (line.length() > 2)
1765 {
1766 QList<QByteArray> tokens = line.split(',');
1767
1768 timeStamp += 5000;
1769 thisFrame.timestamp = timeStamp;
1770 thisFrame.ID = tokens[0].toInt(nullptr, 16);
1771 if (thisFrame.ID > 0x7FF) thisFrame.extended = true;
1772 else thisFrame.extended = false;
1773 thisFrame.bus = 0;
1774 thisFrame.remote = false;
1775 QList<QByteArray> dataTok = tokens[1].split(' ');
1776 thisFrame.len = dataTok.length();
1777 if (thisFrame.len > 8) thisFrame.len = 8;
1778 for (unsigned int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = dataTok[d].toInt(nullptr, 16);
1779
1780 frames->append(thisFrame);
1781 }
1782 else foundErrors = true;
1783 }
1784 inFile->close();
1785 delete inFile;
1786 return !foundErrors;
1787}
1788
1789//4f5,ff 34 23 45 24 e4
1790bool FrameFileIO::saveGenericCSVFile(QString filename, const QVector<CANFrame>* frames)

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected