-
Notifications
You must be signed in to change notification settings - Fork 0
/
dltcan.h
130 lines (96 loc) · 3.15 KB
/
dltcan.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* @licence app begin@
* Copyright (C) 2021 Alexander Wenzel
*
* This file is part of the DLT Multimeter project.
*
* \copyright This code is licensed under GPLv3.
*
* \author Alexander Wenzel <[email protected]>
*
* \file dltcan.h
* @licence end@
*/
#ifndef DLT_CAN_H
#define DLT_CAN_H
#include <QObject>
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QSerialPort>
#include <QTimer>
class DLTCan : public QObject
{
Q_OBJECT
public:
explicit DLTCan(QObject *parent = nullptr);
~DLTCan();
void checkPortName();
void start();
void stop();
QString getInterface() { return interface; }
void setInterface(QString interface) { this->interface = interface; }
// Active
bool getActive() { return active; }
void setActive(bool active) { this->active = active; }
void clearSettings();
void writeSettings(QXmlStreamWriter &xml);
void readSettings(const QString &filename);
void on();
void off();
void sendMessage(unsigned short id,unsigned char *data,int length);
void startCyclicMessage1(int timeout);
void startCyclicMessage2(int timeout);
void setCyclicMessage1(unsigned short id,QByteArray data);
void setCyclicMessage2(unsigned short id,QByteArray data);
void stopCyclicMessage1();
void stopCyclicMessage2();
unsigned short getMessageId() const;
void setMessageId(unsigned short value);
unsigned short getCyclicMessageId1() const;
void setCyclicMessageId1(unsigned short value);
unsigned short getCyclicMessageId2() const;
void setCyclicMessageId2(unsigned short value);
QByteArray getMessageData() const;
void setMessageData(const QByteArray &value);
QByteArray getCyclicMessageData1() const;
void setCyclicMessageData1(const QByteArray &value);
QByteArray getCyclicMessageData2() const;
void setCyclicMessageData2(const QByteArray &value);
int getCyclicMessageTimeout1() const;
void setCyclicMessageTimeout1(int value);
int getCyclicMessageTimeout2() const;
void setCyclicMessageTimeout2(int value);
bool getCyclicMessageActive1() const;
void setCyclicMessageActive1(bool value);
bool getCyclicMessageActive2() const;
void setCyclicMessageActive2(bool value);
signals:
void status(QString text);
void message(unsigned int id,QString direction,QByteArray data);
private slots:
void readyRead();
// Watchdog Timeout
void timeout();
void timeoutCyclicMessage1();
void timeoutCyclicMessage2();
private:
QSerialPort serialPort;
QTimer timer;
QTimer timerRequest;
unsigned int watchDogCounter,watchDogCounterLast;
QString interface;
QString interfaceSerialNumber;
ushort interfaceProductIdentifier;
ushort interfaceVendorIdentifier;
bool active;
QByteArray serialData;
QByteArray rawData;
bool startFound;
bool cyclicMessageActive1,cyclicMessageActive2;
int cyclicMessageTimeout1,cyclicMessageTimeout2;
unsigned short messageId,cyclicMessageId1,cyclicMessageId2;
QByteArray messageData,cyclicMessageData1,cyclicMessageData2;
QTimer timerCyclicMessage1;
QTimer timerCyclicMessage2;
};
#endif // DLT_CAN_H