-
Notifications
You must be signed in to change notification settings - Fork 0
/
firmwareupdater.h
35 lines (28 loc) · 970 Bytes
/
firmwareupdater.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//******** firmwareupdater.h
#ifndef FIRMWAREUPDATER_H
#define FIRMWAREUPDATER_H
#include <QObject>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <vector>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
class FirmwareUpdater : public QObject {
Q_OBJECT
public:
FirmwareUpdater(const QString &comPortName, const QString &firmwarePath, QObject *parent = nullptr);
bool updateFirmware(QSerialPort &serial);
signals:
void updateStatus(const QString &status);
private:
QString portName;
QString firmwarePath;
int baudRate;
void bytesExtractor(QTextStream &in, std::vector<unsigned char> &programBytes);
void resetLine(QTextStream &in);
int getLineCount(QTextStream &in);
bool initializeSerialCommunication(QSerialPort &serial);
bool transmitFirmwareData(QSerialPort &serial, int lineCount, const std::vector<unsigned char> &programBytes);
};
#endif // FIRMWAREUPDATER_H