busmaster log file tokens: 0 = timestamp 1 = Transmission direction 2 = Channel 3 = ID 4 = Type (s = standard, x = extended, sr = standard remote, xr = extended remote) 5 = Data byte length 6-x = The data bytes Sample chunk of a busmaster log: ***BUSMASTER Ver 2.4.0*** ***PROTOCOL CAN*** ***NOTE: PLEASE DO NOT EDIT THIS DOCUMENT*** ***[START LOGGING SESSION]*** ***START DATE AND TIME 8:8:2014 11:
| 1912 | 11:49:12:9690 Rx 1 0x045 s 8 40 00 00 00 00 00 00 00 |
| 1913 | */ |
| 1914 | bool FrameFileIO::loadLogFile(QString filename, QVector<CANFrame>* frames) |
| 1915 | { |
| 1916 | QFile *inFile = new QFile(filename); |
| 1917 | CANFrame thisFrame; |
| 1918 | QByteArray line; |
| 1919 | uint64_t timeStamp = Utility::GetTimeMS(); |
| 1920 | int lineCounter = 0; |
| 1921 | bool foundErrors = false; |
| 1922 | |
| 1923 | if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text)) |
| 1924 | { |
| 1925 | delete inFile; |
| 1926 | return false; |
| 1927 | } |
| 1928 | |
| 1929 | line = inFile->readLine(); //read out the header first and discard it. |
| 1930 | |
| 1931 | while (!inFile->atEnd()) { |
| 1932 | lineCounter++; |
| 1933 | if (lineCounter > 100) |
| 1934 | { |
| 1935 | qApp->processEvents(); |
| 1936 | lineCounter = 0; |
| 1937 | } |
| 1938 | |
| 1939 | line = inFile->readLine().toUpper(); |
| 1940 | if (line.startsWith("***")) continue; |
| 1941 | if (line.length() > 1) |
| 1942 | { |
| 1943 | QList<QByteArray> tokens = line.split(' '); |
| 1944 | if (tokens.length() >= 6) |
| 1945 | { |
| 1946 | QList<QByteArray> timeToks = tokens[0].split(':'); |
| 1947 | timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul)) |
| 1948 | + (timeToks[2].toInt() * (1000ul * 1000ul)) + (timeToks[3].toInt() * 100ul); |
| 1949 | thisFrame.timestamp = timeStamp; |
| 1950 | if (tokens[1].at(0) == 'R') thisFrame.isReceived = true; |
| 1951 | else thisFrame.isReceived = false; |
| 1952 | thisFrame.ID = tokens[3].right(tokens[3].length() - 2).toInt(nullptr, 16); |
| 1953 | if (tokens[4] == "S") { |
| 1954 | thisFrame.extended = false; |
| 1955 | thisFrame.remote = false; |
| 1956 | } else if (tokens[4] == "X") { |
| 1957 | thisFrame.extended = true; |
| 1958 | thisFrame.remote = false; |
| 1959 | } else if (tokens[4] == "SR") { |
| 1960 | thisFrame.extended = false; |
| 1961 | thisFrame.remote = true; |
| 1962 | } else { // XR |
| 1963 | thisFrame.extended = true; |
| 1964 | thisFrame.remote = true; |
| 1965 | } |
| 1966 | thisFrame.bus = tokens[2].toInt() - 1; |
| 1967 | thisFrame.len = tokens[5].toUInt(); |
| 1968 | if (thisFrame.len > 8) thisFrame.len = 8; |
| 1969 | if (!thisFrame.remote) { |
| 1970 | for (unsigned int d = 0; d < thisFrame.len; d++) |
| 1971 | thisFrame.data[d] = tokens[d + 6].toInt(nullptr, 16); |