-
Notifications
You must be signed in to change notification settings - Fork 0
/
vlivox_hunter.h
110 lines (74 loc) · 2.28 KB
/
vlivox_hunter.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
104
105
106
107
108
109
110
#ifndef VLIVOX_HUNTER_H
#define VLIVOX_HUNTER_H
#include <QObject>
#include <QTimer>
#include <QUdpSocket>
#include <QHostAddress>
#include "livox_def.h"
#include "comm/sdk_protocol.h"
#include "command_handler/command_impl.h"
uint16_t calc_crc16( const char* buf, uint len );
uint32_t calc_crc32( const char* buf, uint len );
//=======================================================================================
struct Info
{
QHostAddress address;
int port;
struct
{
uint8_t sof;
uint8_t version;
uint16_t length;
uint8_t packet_type;
uint16_t seq_num;
uint16_t preamble_crc;
uint8_t cmd_set;
uint8_t cmd_id;
} sdk;
std::string broadcast_code;
uint8_t dev_type; //< \ref DeviceType.
uint16_t reserved;
std::string str() const;
};
struct Control
{
livox::CommandSet cmd_set = livox::kCommandSetGeneral;
livox::GeneralCommandID cmd_id = livox::kCommandIDGeneralBroadcast;
livox::CommandType packet_type = livox::kCommandTypeCmd;
};
enum
{
local_data_port = 55000,
local_cmd_port = 56000,
livox_port = 65000
};
//=======================================================================================
class VLivox_Hunter : public QObject
{
Q_OBJECT
public:
explicit VLivox_Hunter( const QString broadcast_code = "",
const QString livox_ip = "",
QObject* parent = nullptr );
//-----------------------------------------------------------------------------------
signals:
void receive( const Info&, const Control& );
void send( const Info&, const Control& );
//-----------------------------------------------------------------------------------
private:
QUdpSocket _recv;
QUdpSocket _cmd;
QString _broadcast_code;
QString _livox_ip;
QTimer *_heart_timer;
uint16_t _seq_num = 0;
Control _control;
//-----------------------------------------------------------------------------------
private slots:
void _on_udp();
void _read_one_udp();
void _to_udp();
void _write_one_udp();
};
//=======================================================================================
#endif // VLIVOX_HUNTER_H