forked from dihonglongxi/FactoryTestApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JLinkManager.h
70 lines (50 loc) · 1.63 KB
/
JLinkManager.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <QProcess>
#include <QSettings>
#include "Logger.h"
#include "JLinkSDK/JLinkARMDLL.h"
class JLinkManager : public QObject
{
Q_OBJECT
public:
enum State {unknown, waitingTestResponse, connectionTested};
explicit JLinkManager(const QSharedPointer<QSettings> &settings, QObject *parent = Q_NULLPTR);
~JLinkManager() Q_DECL_OVERRIDE;
void setLogger(const QSharedPointer<Logger> &logger) {_logger = logger;}
void setSN(const QString& serialNumber);
QString getSN() const;
public slots:
State state() const {return _state;}
bool isConnected() const;
void selectByUSB();
void open();
void setDevice(const QString& device);
void select(int interface = JLINKARM_TIF_SWD);
void setSpeed(int speed);
void connect();
int erase();
void reset();
void go();
int downloadFile(const QString& fileName, int adress);
void close();
void on_establishConnection();
void on_startScript(const QString& scriptFile);
void readStandardOutput();
signals:
void establishConnection();
void startScript(const QString& scriptFile);
private:
void clearErrorBuffer();
void logOut(const char* log) {_logger->logInfo(log);}
void errorOut(const char* log) {_logger->logDebug(QString("JLINK ERROR: %1").arg(log));}
QSharedPointer<QSettings> _settings;
QSharedPointer<Logger> _logger;
State _state = unknown;
QString _device;
int _targetInterface = JLINKARM_TIF_SWD;
int _speed = 5000;
int _hostInterface = JLINKARM_HOSTIF_USB;
QString _SN; // JLink serial number
QByteArray _errorBuffer;
QProcess _proc;
};