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/QSet>
8#include <QtCore/QTime>
9#include <QtCore/QVariantList>
10
12class Bootloader;
13class FirmwareImage;
14class QThread;
15class QTimer;
16
21class PX4FirmwareUpgradeThreadWorker : public QObject
22{
23 Q_OBJECT
24
25public:
28
29signals:
30 void updateProgress (int curr, int total);
31 void foundBoard (bool firstAttempt, const QGCSerialPortInfo& portInfo, int type, QString boardName);
32 void noBoardFound (void);
33 void boardGone (void);
34 void foundBoardInfo (int bootloaderVersion, int boardID, int flashSize);
35 void error (const QString& errorString);
36 void status (const QString& statusText);
37 void eraseStarted (void);
38 void eraseComplete (void);
39 void flashComplete (void);
40 void portsAvailable (const QVariantList& ports);
41
42private slots:
43 void _init (void);
44 void _startFindBoardLoop(void);
45 void _reboot (void);
46 void _flash (void);
47 void _findBoardOnce (void);
48 void _updateProgress (int curr, int total) { emit updateProgress(curr, total); }
49 void _cancel (void);
50 void _setTargetPort (const QString& systemLocation);
51
52private:
53 bool _erase (void);
54 QVariantList _buildPortDescriptors() const;
55 void _resumeDiscovery (void);
56
58
59 Bootloader* _bootloader = nullptr;
60 QTimer* _findBoardTimer = nullptr;
61 QTime _elapsed;
62 bool _foundBoard = false;
63 bool _findBoardFirstAttempt = true;
64 bool _targetSeenAtLeastOnce = false;
65 QString _targetSystemLocation;
66 QString _targetSerialNumber;
67 QSet<QString> _ignoredPorts;
68 QGCSerialPortInfo _foundBoardPortInfo;
69};
70
75{
76 Q_OBJECT
77
78public:
79 PX4FirmwareUpgradeThreadController(QObject* parent = nullptr);
81
84 void startFindBoardLoop(void);
85
86 void cancel(void);
87
89 void reboot(void) { emit _rebootOnThread(); }
90
91 void flash(const FirmwareImage* image);
92
94 void setTargetPort(const QString& systemLocation) { emit _setTargetPortOnThread(systemLocation); }
95
96 const FirmwareImage* image(void) { return _image; }
97
98signals:
99 void foundBoard (bool firstAttempt, const QGCSerialPortInfo &portInfo, int boardType, QString boardName);
100 void noBoardFound (void);
101 void boardGone (void);
102 void foundBoardInfo (int bootloaderVersion, int boardID, int flashSize);
103 void error (const QString& errorString);
104 void status (const QString& status);
105 void eraseStarted (void);
106 void eraseComplete (void);
107 void flashComplete (void);
108 void updateProgress (int curr, int total);
109 void portsAvailable (const QVariantList& ports);
110
111 // Internal signals to communicate with thread worker
112 void _initThreadWorker (void);
114 void _rebootOnThread (void);
115 void _flashOnThread (void);
116 void _cancel (void);
117 void _setTargetPortOnThread (const QString& systemLocation);
118
119private slots:
120 void _foundBoard (bool firstAttempt, const QGCSerialPortInfo& portInfo, int type, QString name) { emit foundBoard(firstAttempt, portInfo, type, name); }
121 void _noBoardFound (void) { emit noBoardFound(); }
122 void _boardGone (void) { emit boardGone(); }
123 void _foundBoardInfo (int bootloaderVersion, int boardID, int flashSize) { emit foundBoardInfo(bootloaderVersion, boardID, flashSize); }
124 void _error (const QString& errorString) { emit error(errorString); }
125 void _status (const QString& statusText) { emit status(statusText); }
126 void _eraseStarted (void) { emit eraseStarted(); }
127 void _eraseComplete (void) { emit eraseComplete(); }
128 void _flashComplete (void) { emit flashComplete(); }
129 void _portsAvailable (const QVariantList& ports) { emit portsAvailable(ports); }
130
131private:
132 void _updateProgress(int curr, int total) { emit updateProgress(curr, total); }
133
134 PX4FirmwareUpgradeThreadWorker* _worker = nullptr;
135 QThread* _workerThread = nullptr;
136
137 const FirmwareImage* _image;
138};
QString errorString
Error error
Bootloader Utility routines. Works with PX4 and 3DR Radio bootloaders.
Definition Bootloader.h:16
Support for Intel Hex firmware file.
Provides methods to interact with the bootloader. The commands themselves are signalled across to PX4...
void _setTargetPortOnThread(const QString &systemLocation)
void updateProgress(int curr, int total)
void portsAvailable(const QVariantList &ports)
void setTargetPort(const QString &systemLocation)
Tells the worker to flash a specific port (selected by the user) when it appears in bootloader mode.
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 portsAvailable(const QVariantList &ports)
void error(const QString &errorString)
void foundBoardInfo(int bootloaderVersion, int boardID, int flashSize)
void status(const QString &statusText)
void updateProgress(int curr, int total)
QGC's version of Qt QSerialPortInfo. It provides additional information about board types that QGC ca...