forked from donaloconnor/automon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserialhelper.h
69 lines (59 loc) · 2.79 KB
/
serialhelper.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
#ifndef SERIALHELPER_H
#define SERIALHELPER_H
/*
==================================================================================================
| serialhelper.h |
| Part of the Automon application. |
| |
| Final Year Project - "An Embedded Automotive Monitoring Device" |
| |
| By Donal O' Connor for completion of B.Sc (Hons) Software Development and Computer Networking |
| Email: [email protected] |
| Website/Blog: http://automon.killarneyonline.eu |
| |
| Cork Institute of Technology, Cork, Ireland - http://www.cit.ie/ |
| |
| Copyright © 2009 Donal O'Connor <[email protected]> |
==================================================================================================
The SerialHelper class is one of the main critical classes of Automon. it is responsible for the
communication between Automon and the ELM327. It uses the QExtSerialPort library to perform this communication.
It handles the scheduling of monitoring sensors and sending commands to ELM327.
*/
#include <QThread>
#include <QMutex>
#include <QtSerialPort/QSerialPort> // [LA]
//#ifdef win32
// #include <QtSerialPort/QtSerialPort>
// #include <QtSerialPort/QSerialPortInfo>
//#else
// #include
// #include "QtSerialPort/qserialportinfo.h"
//#endif
#include "sensor.h"
#include "command.h"
namespace AutomonKernel
{
class SerialHelper : public QThread
{
public:
SerialHelper(QString port="/dev/ttyUSB0");
~SerialHelper();
void run();
bool addActiveSensor(Sensor * sensor);
bool removeActiveSensorByCommand(QString command);
bool isMonitoring();
bool sendCommand(Command & command, int timeout = 5000);
void clearReadBuffer();
void setMonitoring(bool);
void removeAllActiveSensors();
private:
QSerialPort * m_connection;
QList<Sensor*> m_activeSensors;
bool m_isMonitoring;
bool m_isPaused;
bool m_pausedStarted;
bool m_stop;
QMutex m_mutexLock;
};
}
#endif // SERIALHELPER_H