-
Notifications
You must be signed in to change notification settings - Fork 1
/
proto.h
137 lines (112 loc) · 3.16 KB
/
proto.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#ifndef _PROTO_H__
#define _PROTO_H__
#define PACKED __attribute__((__packed__))
#define AWLINK_MAGIC 0xFA
#define AWLINK_IDSRC_MASTER 0
#define AWLINK_IDSRC_CLIENT 1
#define AWLINK_PARSE_STEP_MAGIC 1
#define AWLINK_PARSE_STEP_LENGTH 2
#define AWLINK_PARSE_STEP_ID_SRC 3
#define AWLINK_PARSE_STEP_I_ID 4
#define AWLINK_PARSE_STEP_SI_ID 5
#define AWLINK_PARSE_STEP_DATA 6
#define AWLINK_PARSE_STEP_CHECKSUM1 7
#define AWLINK_PARSE_STEP_CHECKSUM2 8
#define AWLINK_PARSE_STEP_OK 9
#define AWLINK_PARSE_STEP_FAIL 10
#define AWLINK_ITEM_SYSTEM 0
#define AWLINK_ITEM_STATUS 1
#define AWLINK_ITEM_CONTROL 2
#define AWLINK_ITEM_MISSION 3
#define AWLINK_ITEM_PARAM 4
#define AWLINK_ITEM_LOG 5
#define AWLINK_ITEM_FILE 6
#define AWLINK_ITEM_SYSTEM_ACK 0
#define AWLINK_ITEM_SYSTEM_AWLINK_VER 1
#define AWLINK_ITEM_SYSTEM_AWPILOT_VER 2
#define AWLINK_ITEM_SYSTEM_HEART 3
#define AWLINK_ITEM_SYSTEM_MSG 4
#define AWLINK_ITEM_STATUS_BASIC_INFO 0
#define AWLINK_ITEM_STATUS_MISSION_INFO 1
#define AWLINK_ITEM_STATUS_GPS_INFO 2
#define AWLINK_ITEM_STATUS_SENSOR_INFO 3
#define AWLINK_ITEM_STATUS_SENSOR_CALIB_INFO 4
#define AWLINK_ITEM_STATUS_USER1_INFO 5
#define AWLINK_ITEM_CONTROL_JOYSTICK 0
#define AWLINK_ITEM_CONTROL_STATUS_RATE 1
#define AWLINK_ITEM_CONTROL_CALIBRATE 2
#define AWLINK_ITEM_CONTROL_MODE 3
#define AWLINK_ITEM_CONTROL_ARUCO_DIST 11
typedef struct {
uint8_t heart;
}awlink_system_heart_s;
typedef struct {
uint8_t ack;
uint8_t item_id;
uint8_t subitem_id;
}awlink_system_ack_s;
typedef struct{
float att[3];
float vel_ned[3];
float pos_ned[3];
uint8_t status;
uint8_t mode;
uint8_t capacity;
uint8_t voltage;
bool charge;
bool headfree;
bool armed;
}awlink_status_base_info_s;
typedef struct {
uint8_t magic;
uint8_t length;
uint8_t id_src;
uint8_t item_id;
uint8_t subitem_id;
uint8_t *data;
uint16_t checksum;
}awlink_msg_s;
typedef struct {
uint8_t type;
uint16_t awlink_parse_error;
uint8_t awlink_parse_step;
uint8_t awlink_parse_data_count;
uint16_t awlink_parse_checksum;
awlink_msg_s awlink_package;
}awlink_decode_s;
enum cmd {
CMD_SAFE_MODE = 83,
CMD_WING_PROTECTION,
CMD_CONTROL_YAW,
CMD_CONTROL_ALT,
CMD_IMG_LOAD,
CMD_TOF_ALTHOLD,//88
CMD_TAKEOFF_ALT,
CMD_INFRARED_SHOOTING,
};
enum action_cmd {
CMD_ACC = 0, //校准
CMD_TAKEOFF, //起飞
CMD_LAND, //降落
CMD_FORWARD_TURN, //前翻
CMD_BACK_TURN, //后翻
CMD_LEFT_TURN, //左翻
CMD_RIGHT_TURN, //右翻
CMD_UP, //上升
CMD_DOWN, //下降
CMD_LEFT, //向左
CMD_RIGHT, //向右
CMD_FORWARD, //向前
CMD_BACK, //向后
CMD_LEFT_YAW, //左旋
CMD_RIGHT_YAW, //右旋
CMD_TAKE_PHOTO, //拍照
CMD_TOF_ALT, //定高
CMD_TAKEOFF_ALTH, //起飞高度
CMD_MODE_CHANGE, //模式切换
CMD_SHOOT, //射击
CMD_ARUCO,
};
void recv_udp(int fd);
uint8_t batt_get_cap();
#endif