ULogParser.h 1.49 KB
Newer Older
1 2 3 4 5
#ifndef ULOGPARSER_H
#define ULOGPARSER_H

#include <QGeoCoordinate>
#include <QDebug>
6
#include <QCoreApplication>
7 8 9 10 11 12 13

#include "GeoTagController.h"

#define ULOG_FILE_HEADER_LEN 16

class ULogParser
{
14 15
    Q_DECLARE_TR_FUNCTIONS(ULogParser)

16 17 18
public:
    ULogParser();
    ~ULogParser();
19 20 21

    /// @return true: failed, errorMessage set
    bool getTagsFromLog(QByteArray& log, QList<GeoTagWorker::cameraFeedbackPacket>& cameraFeedback, QString& errorMessage);
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

private:

    QMap<QString, int> _cameraCaptureOffsets; // <fieldName, fieldOffset>
    int _cameraCaptureMsgID;

    const char _ULogMagic[8] = {'U', 'L', 'o', 'g', 0x01, 0x12, 0x35};

    int sizeOfType(QString& typeName);
    int sizeOfFullType(QString &typeNameFull);
    QString extractArraySize(QString& typeNameFull, int& arraySize);

    bool parseFieldFormat(QString& fields);

    enum class ULogMessageType : uint8_t {
        FORMAT = 'F',
        DATA = 'D',
        INFO = 'I',
        PARAMETER = 'P',
        ADD_LOGGED_MSG = 'A',
        REMOVE_LOGGED_MSG = 'R',
        SYNC = 'S',
        DROPOUT = 'O',
        LOGGING = 'L',
    };

    #define ULOG_MSG_HEADER_LEN 3
    struct ULogMessageHeader {
        uint16_t msgSize;
        uint8_t msgType;
    };

    struct ULogMessageFormat {
        uint16_t msgSize;
        uint8_t msgType;

        char format[2096];
    };

    struct ULogMessageAddLogged {
	  uint16_t msgSize;
      uint8_t msgType;

	  uint8_t multiID;
	  uint16_t msgID;
	  char msgName[255];
	};

};

#endif // ULOGPARSER_H