forked from collin80/SavvyCAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialbusconnection.h
56 lines (43 loc) · 1.37 KB
/
serialbusconnection.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
#ifndef SERIALBUSCONNECTION_H
#define SERIALBUSCONNECTION_H
#include "canconnection.h"
#include "canframemodel.h"
#include <QCanBusDevice>
#include <QTimer>
/*
QCanBusDevice::UserKey
0x00000001 - enable silent mode
0x00000002 - enable loopback mode
0x00000004 - disable auto retransmissions
0x00000008 - enable terminator
0x00000010 - enable automatic bus off recovery
*/
#define EN_SILENT_MODE 0x00000001
#define EN_LOOPBACK_MODE 0x00000002
#define DIS_AUTO_RETRANSMISSIONS 0x00000004
#define EN_TERMINATOR 0x00000008
#define EN_AUTOMATIC_BUSOFF_RECOVERY 0x00000010
class SerialBusConnection : public CANConnection
{
Q_OBJECT
public:
SerialBusConnection(QString portName, QString driverName);
virtual ~SerialBusConnection();
protected:
virtual void piStarted();
virtual void piStop();
virtual void piSetBusSettings(int pBusIdx, CANBus pBus);
virtual bool piGetBusSettings(int pBusIdx, CANBus& pBus);
virtual void piSuspend(bool pSuspend);
virtual bool piSendFrame(const CANFrame&);
void disconnectDevice();
private slots:
void errorReceived(QCanBusDevice::CanBusError) const;
void framesWritten(qint64 count);
void framesReceived();
void testConnection();
protected:
QCanBusDevice *mDev_p = nullptr;
QTimer mTimer;
};
#endif // SERIALBUSCONNECTION_H