forked from opelpanfan/PowerTune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobd.h
103 lines (79 loc) · 2.14 KB
/
obd.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
/*
* file obd.h
* Copyright (C) 2018 Markus Ippy
*
* Communications class for OBD2 Live readouts
*
* No warranty is made or implied. You use this program at your own risk.
*/
#ifndef OBD_H
#define OBD_H
#include <QObject>
#include <QTimer>
#include <QThread>
#include <QtSerialPort/QSerialPort>
namespace PIDS {
enum ENUM {
SupportedPids0to20 = 0x00,
Monitorstatus = 0x01,
FreezeDTC = 0x02,
FuelsystemStatus = 0x03,
CalcEngLoad = 0x04,
EngCoolantTemp = 0x05,
ShortTermFueltrimB1 = 0x06,
LongTermFueltrimB1 = 0x07,
ShortTermFueltrimB2 = 0x08,
LongTermFueltrimB2 = 0x09,
FuelPressure = 0x0A,
IntakeManifoldPress = 0x0B,
EngineRPM = 0x0C,
VehicleSpeed = 0x0D,
TimingAdvance = 0x0E,
IntakeAirTemp = 0x0F,
MAFrate = 0x10,
ThrottlePosition = 0x11,
ComsecAirStatus = 0x12,
OxygenSenspresent = 0x13,
O2sensor1 = 0x14
};
}
class SerialPort;
class DashBoard;
class OBD : public QObject
{
Q_OBJECT
public:
explicit OBD(QObject *parent = 0);
explicit OBD(DashBoard *dashboard, QObject *parent = 0);
Q_INVOKABLE void clear() const;
Q_INVOKABLE void initSerialPort();
Q_INVOKABLE void openConnection(const QString &portName);
Q_INVOKABLE void closeConnection();
public slots:
public:
void writeRequest(QByteArray);
private:
DashBoard *m_dashboard;
SerialPort *m_serial;
QStringList *m_ecuList;
qint64 m_bytesWritten;
QByteArray m_readData;
QTimer m_timer;
QByteArray m_buffer;
QByteArray m_message;
QByteArray m_writeData;
int m_units;
signals:
void sig_finished();
void sig_error(QString err);
void sig_ApexiDataAvailable(QByteArray);
public slots:
void readyToRead();
void handleTimeout();
void handleBytesWritten(qint64 bytes);
void handleError(QSerialPort::SerialPortError error);
void messageconstructor(const QByteArray &buffer);
void sendRequest(int requestIndex);
void readData(QByteArray serialdata);
};
#endif // OBD_H