2023-12-01 14:28:07 +01:00
|
|
|
#ifndef DOWNLOAD_THREAD_H_INCLUDED
|
|
|
|
#define DOWNLOAD_THREAD_H_INCLUDED
|
|
|
|
|
|
|
|
#include <QThread>
|
|
|
|
#include <QString>
|
2023-12-08 19:00:43 +01:00
|
|
|
#include <QByteArray>
|
2023-12-01 14:28:07 +01:00
|
|
|
|
|
|
|
class hwinf;
|
|
|
|
class DownloadThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-12-08 19:00:43 +01:00
|
|
|
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
|
|
|
|
2023-12-02 09:44:18 +01:00
|
|
|
DownloadThread(hwinf *hw);
|
2023-12-01 14:28:07 +01:00
|
|
|
~DownloadThread();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// download thread does not have a running event queue, and therefore
|
|
|
|
// no slots. signals work the usual way.
|
|
|
|
void run() override;
|
|
|
|
|
|
|
|
private:
|
2023-12-08 19:00:43 +01:00
|
|
|
DownloadResult sendStatus(int ret) const;
|
|
|
|
DownloadResult sendNextAddress(int bNum) const;
|
|
|
|
DownloadResult sendNextDataBlock(QByteArray const &binary, int bNum) const;
|
|
|
|
bool startBootloader() const;
|
|
|
|
bool stopBootloader() const;
|
|
|
|
QByteArray loadBinaryDCFile(QString dcFileName) const;
|
|
|
|
bool resetDeviceController() const;
|
|
|
|
DownloadResult dcDownloadBinary(QByteArray const &b) const;
|
|
|
|
|
2023-12-01 14:28:07 +01:00
|
|
|
hwinf *m_hw;
|
|
|
|
QString m_fileToDownload;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOWNLOAD_THREAD_H_INCLUDED
|