-
Notifications
You must be signed in to change notification settings - Fork 286
/
can_structs.h
54 lines (44 loc) · 1.29 KB
/
can_structs.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
#ifndef CAN_STRUCTS_H
#define CAN_STRUCTS_H
#include <QObject>
#include <QVector>
#include <stdint.h>
#include <QCanBusFrame>
//Now inherits from the built-in CAN frame class from Qt. This should be more future proof and easier to integrate with other code
struct CANFrame : public QCanBusFrame
{
public:
int bus;
bool isReceived; //did we receive this or send it?
uint64_t timedelta;
uint32_t frameCount; //used in overwrite mode
friend bool operator<(const CANFrame& l, const CANFrame& r)
{
qint64 lStamp = l.timeStamp().seconds() * 1000000 + l.timeStamp().microSeconds();
qint64 rStamp = r.timeStamp().seconds() * 1000000 + r.timeStamp().microSeconds();
return lStamp < rStamp;
}
CANFrame()
{
setFrameId(0);
bus = 0;
setExtendedFrameFormat(false);
setFrameType(QCanBusFrame::DataFrame);
isReceived = true;
timedelta = 0;
frameCount = 1;
}
};
class CANFltObserver
{
public:
quint32 id;
quint32 mask;
QObject * observer; //used to target the specific object that setup this filter
bool operator ==(const CANFltObserver &b) const
{
if ( (id == b.id) && (mask == b.mask) && (observer == b.observer) ) return true;
return false;
}
};
#endif // CAN_STRUCTS_H