PX4FirmwareUpgradeWorker.h 1.62 KB
Newer Older
1 2 3 4
#ifndef PX4FIRMWAREUPGRADEWORKER_H
#define PX4FIRMWAREUPGRADEWORKER_H

#include <QObject>
5
#include <QJsonDocument>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

#include <SerialLink.h>

class PX4FirmwareUpgradeWorker : public QObject
{
    Q_OBJECT
public:
    explicit PX4FirmwareUpgradeWorker(QObject *parent = 0);
    static PX4FirmwareUpgradeWorker* putWorkerInThread(QObject *parent);

signals:
    void detectionStatusChanged(const QString& status);
    void upgradeStatusChanged(const QString& status);
    void upgradeProgressChanged(int percent);
    void validPortFound(const QString& portName);
    
public slots:

    /**
     * @brief Continously scan for bootloaders
     * @return
     */
28
    void startContinousScan();
29 30 31 32 33 34 35 36 37

    /**
     * @brief Detect connected PX4 bootloaders
     *
     * If a bootloader was found, the link will be opened to this
     * bootloader and ready for flashing when returning from the call.
     *
     * @return true if found on one link, false else
     */
38
    void detect();
39 40 41 42 43

    /**
     * @brief Upgrade the firmware using the currently connected link
     * @param filename file name / path of the firmware file
     */
44 45 46 47 48 49 50
    void upgrade();

    /**
     * @brief Load firmware from disk into memory
     * @param filename
     */
    void loadFirmware(const QString &filename);
51 52 53 54 55 56 57 58

    /**
     * @brief Receive bytes from a link
     * @param link
     * @param b
     */
    void receiveBytes(LinkInterface* link, QByteArray b);

59 60 61 62 63 64 65 66
    /**
     * @brief Abort upgrade worker
     */
    void abort();

protected:
    bool exitThread;

67 68 69
private:
    SerialLink *link;
    bool insync;
70
    QJsonDocument firmware;
71 72 73
};

#endif // PX4FIRMWAREUPGRADEWORKER_H