Add functionality from hwapi to download device controller to dc-hardware
This commit is contained in:
34
update.h
34
update.h
@@ -4,9 +4,10 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QByteArray>
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "DCPlugin/include/hwapi.h"
|
||||
#include "plugins/interfaces.h"
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
@@ -15,9 +16,6 @@
|
||||
#endif
|
||||
|
||||
class Update;
|
||||
struct ScopedPointerCustomDeleter {
|
||||
static void cleanup(Update *pointer);
|
||||
};
|
||||
|
||||
// TODO: check hardware compatibility
|
||||
// TODO: opkg commandos
|
||||
@@ -25,7 +23,7 @@ struct ScopedPointerCustomDeleter {
|
||||
class Update : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
QScopedPointer<hwinf> m_hw;
|
||||
hwinf *m_hw;
|
||||
char const *m_serialInterface;
|
||||
char const *m_baudrate;
|
||||
QFile m_update_ctrl_file;
|
||||
@@ -41,16 +39,34 @@ class Update : public QObject {
|
||||
QStringList split(QString line, QChar sep = ',');
|
||||
|
||||
bool execUpdateScript();
|
||||
|
||||
public:
|
||||
explicit Update(QString update_ctrl_file,
|
||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||
|
||||
static hwinf *loadDCPlugin(QDir const &plugInDir, QString const &fn);
|
||||
|
||||
|
||||
explicit Update(hwinf *hw,
|
||||
QString update_ctrl_file,
|
||||
QString workingDir = ".",
|
||||
QObject *parent = nullptr,
|
||||
hwinf *hw = nullptr,
|
||||
char const *serialInterface = SERIAL_PORT,
|
||||
char const *baudrate = "115200");
|
||||
virtual ~Update() override;
|
||||
bool doUpdate();
|
||||
|
||||
bool const m_delete;
|
||||
private:
|
||||
DownloadResult sendStatus(int ret) const;
|
||||
DownloadResult sendNextAddress(int bNum) const;
|
||||
DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const;
|
||||
DownloadResult dc_downloadBinary(QByteArray const &binary) const;
|
||||
|
||||
bool startBootloader() const;
|
||||
bool stopBootloader() const;
|
||||
bool openSerial(int br, QString baudrate, QString comPort) const;
|
||||
void closeSerial() const;
|
||||
bool resetDeviceController() const;
|
||||
QByteArray loadBinaryDCFile(QString filename) const;
|
||||
bool downloadBinaryToDC(QString const &bFile) const;
|
||||
};
|
||||
#endif // UPDATE_H_INCLUDED
|
||||
|
Reference in New Issue
Block a user