forked from chcbaram/QtWiznetCanBus
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWiznetCanBackend.h
56 lines (43 loc) · 1.28 KB
/
WiznetCanBackend.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 WIZNET_CAN_BACKEND_H_
#define WIZNET_CAN_BACKEND_H_
#include <QCanBusDevice>
#include <QUdpSocket>
#include "hw.h"
class WiznetCanBackend : public QCanBusDevice
{
Q_OBJECT
public:
WiznetCanBackend(quint16 localPort, const QHostAddress& remoteAddr,
quint16 remotePort);
bool writeFrame(const QCanBusFrame& frame) override;
QString interpretErrorFrame(const QCanBusFrame& errorFrame) override;
static QList<QCanBusDeviceInfo> interfaces();
uint32_t canDriverAvailable(void);
bool canDriverFlush(void);
uint8_t canDriverRead(void);
uint32_t canDriverWrite(uint8_t *p_data, uint32_t length);
QCanBusDevice::CanBusStatus canGetStatus();
protected:
bool open() override;
void close() override;
void timerEvent(QTimerEvent*) override;
private:
quint16 localPort_;
QHostAddress remoteAddr_;
quint16 remotePort_;
QUdpSocket sock_;
int timerId_;
void handlePacket(const QByteArray& data);
cmd_can_t cmd_can;
cmd_can_driver_t cmd_can_driver;
uint8_t cmd_can_buf[512*1024];
qbuffer_t cmd_can_q;
qint64 offset_time;
uint32_t ping_cnt;
bool is_connected;
CanBusStatus can_bus_status;
private slots:
void dataAvailable();
// void outQueueTimer();
};
#endif