QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PX4FirmwareUpgradeThread.h
Go to the documentation of this file.
1#pragma once
2
3
4#include "QGCSerialPortInfo.h"
5
6#include <QtCore/QObject>
7#include <QtCore/QTime>
8
10class Bootloader;
11class FirmwareImage;
12class QThread;
13class QTimer;
14
18class PX4FirmwareUpgradeThreadWorker : public QObject
19{
20 Q_OBJECT
21
22public:
25
26signals:
27 void updateProgress (int curr, int total);
28 void foundBoard (bool firstAttempt, const QGCSerialPortInfo& portInfo, int type, QString boardName);
29 void noBoardFound (void);
30 void boardGone (void);
31 void foundBoardInfo (int bootloaderVersion, int boardID, int flashSize);
32 void error (const QString& errorString);
33 void status (const QString& statusText);
34 void eraseStarted (void);
35 void eraseComplete (void);
36 void flashComplete (void);
37
38private slots:
39 void _init (void);
40 void _startFindBoardLoop(void);
41 void _reboot (void);
42 void _flash (void);
43 void _findBoardOnce (void);
44 void _updateProgress (int curr, int total) { emit updateProgress(curr, total); }
45 void _cancel (void);
46
47private:
48 bool _findBoardFromPorts(QGCSerialPortInfo& portInfo, QGCSerialPortInfo::BoardType_t& boardType, QString& boardName);
49 bool _erase (void);
50
52
53 Bootloader* _bootloader = nullptr;
54 QTimer* _findBoardTimer = nullptr;
55 QTime _elapsed;
56 bool _foundBoard = false;
57 bool _boardIsSiKRadio = false;
58 bool _findBoardFirstAttempt = true;
59 QGCSerialPortInfo _foundBoardPortInfo;
60};
61
65{
66 Q_OBJECT
67
68public:
69 PX4FirmwareUpgradeThreadController(QObject* parent = nullptr);
71
74 void startFindBoardLoop(void);
75
76 void cancel(void);
77
79 void reboot(void) { emit _rebootOnThread(); }
80
81 void flash(const FirmwareImage* image);
82
83 const FirmwareImage* image(void) { return _image; }
84
85signals:
86 void foundBoard (bool firstAttempt, const QGCSerialPortInfo &portInfo, int boardType, QString boardName);
87 void noBoardFound (void);
88 void boardGone (void);
89 void foundBoardInfo (int bootloaderVersion, int boardID, int flashSize);
90 void error (const QString& errorString);
91 void status (const QString& status);
92 void eraseStarted (void);
93 void eraseComplete (void);
94 void flashComplete (void);
95 void updateProgress (int curr, int total);
96
97 // Internal signals to communicate with thread worker
98 void _initThreadWorker (void);
100 void _rebootOnThread (void);
101 void _flashOnThread (void);
102 void _cancel (void);
103
104private slots:
105 void _foundBoard (bool firstAttempt, const QGCSerialPortInfo& portInfo, int type, QString name) { emit foundBoard(firstAttempt, portInfo, type, name); }
106 void _noBoardFound (void) { emit noBoardFound(); }
107 void _boardGone (void) { emit boardGone(); }
108 void _foundBoardInfo (int bootloaderVersion, int boardID, int flashSize) { emit foundBoardInfo(bootloaderVersion, boardID, flashSize); }
109 void _error (const QString& errorString) { emit error(errorString); }
110 void _status (const QString& statusText) { emit status(statusText); }
111 void _eraseStarted (void) { emit eraseStarted(); }
112 void _eraseComplete (void) { emit eraseComplete(); }
113 void _flashComplete (void) { emit flashComplete(); }
114
115private:
116 void _updateProgress(int curr, int total) { emit updateProgress(curr, total); }
117
118 PX4FirmwareUpgradeThreadWorker* _worker = nullptr;
119 QThread* _workerThread = nullptr;
120
121 const FirmwareImage* _image;
122};
QString errorString
Error error
Bootloader Utility routines. Works with PX4 and 3DR Radio bootloaders.
Definition Bootloader.h:19
Support for Intel Hex firmware file.
Provides methods to interact with the bootloader. The commands themselves are signalled across to PX4...
void updateProgress(int curr, int total)
void reboot(void)
Sends a reboot command to the bootloader.
void error(const QString &errorString)
void startFindBoardLoop(void)
Begins the process of searching for a supported board connected to any serial port....
void flash(const FirmwareImage *image)
void foundBoard(bool firstAttempt, const QGCSerialPortInfo &portInfo, int boardType, QString boardName)
void status(const QString &status)
void foundBoardInfo(int bootloaderVersion, int boardID, int flashSize)
Used to run bootloader commands on a separate thread. These routines are mainly meant to to be called...
void foundBoard(bool firstAttempt, const QGCSerialPortInfo &portInfo, int type, QString boardName)
void error(const QString &errorString)
void foundBoardInfo(int bootloaderVersion, int boardID, int flashSize)
void status(const QString &statusText)
void updateProgress(int curr, int total)