-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPackets.h
163 lines (147 loc) · 3.46 KB
/
Packets.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef HEADER_PACKETS
#define HEADER_PACKETS
#pragma pack(1) // prevents padding of structs to allow accurate (undefined) pointer access
// All packets derive from this class
struct MSP_PACKET{
public: // might actually make these protected
MSP_PACKET():last_changed(0){}
uint8_t message_id;
uint8_t message_length;
uint32_t last_changed;
};
// All packets used for retrieving data from the FC derive from this class
struct MSP_PACKET_GET : public MSP_PACKET{
};
// All packets used for sending data to the FC derive from this class
struct MSP_PACKET_SET : public MSP_PACKET{
};
struct MSP_IDENT : public MSP_PACKET_GET{
MSP_IDENT(){
message_id = 100;
message_length = 7;
}
uint8_t version;
uint8_t multitype;
uint8_t msp_version;
uint32_t capability;
};
struct MSP_STATUS : public MSP_PACKET_GET{
MSP_STATUS(){
message_id = 101;
message_length = 11;
}
uint16_t cycle_time;
uint16_t i2c_errors_count;
uint16_t sensor;
uint32_t flag;
uint8_t global_conf;
};
struct MSP_RAW_IMU : public MSP_PACKET_GET{
MSP_RAW_IMU(){
message_id = 102;
message_length = 18;
}
int16_t accx;
int16_t accy;
int16_t accz;
int16_t gyrx;
int16_t gyry;
int16_t gyrz;
int16_t magx;
int16_t magy;
int16_t magz;
};
struct MSP_SERVO : public MSP_PACKET_GET{
MSP_SERVO(){
message_id = 103;
message_length = 16;
}
uint16_t servo[8];
};
struct MSP_MOTOR : public MSP_PACKET_GET{
MSP_MOTOR(){
message_id = 104;
message_length = 16;
}
uint16_t motor[8];
};
struct MSP_RC : public MSP_PACKET_GET{
MSP_RC(){
message_id = 105;
message_length = 32;
}
uint16_t channel[16];
};
struct MSP_RAW_GPS : public MSP_PACKET_GET{
MSP_RAW_GPS(){
message_id = 106;
message_length = 16;
}
uint8_t fix; // might be able to change this to bool
uint8_t num_sat;
uint32_t lattitude; // 1 / 10 000 000 degree
uint32_t longitude; // 1 / 10 000 000 degree
uint16_t altitude; // metre
uint16_t speed; // cm / s
uint16_t ground_course; // degree * 10
};
struct MSP_ATTITUDE : public MSP_PACKET_GET{
MSP_ATTITUDE(){
message_id = 108;
message_length = 6;
}
int16_t angx;
int16_t angy;
int16_t heading;
};
struct MSP_ANALOG : public MSP_PACKET_GET{
MSP_ANALOG(){
message_id = 110;
message_length = 7;
}
uint8_t vbat;
uint16_t intPowerMeterSum;
uint16_t rssi;
uint16_t amperage;
};
struct MSP_SET_RAW_RC : public MSP_PACKET_SET{
MSP_SET_RAW_RC()
{
message_id = 200;
message_length = 32;
for (int i = 0; i < 16; i++)
(&roll)[i] = 1500;
throttle = 1000;
}
uint16_t roll;
uint16_t pitch;
uint16_t throttle;
uint16_t yaw;
uint16_t aux1;
uint16_t aux2;
uint16_t aux3;
uint16_t aux4;
uint16_t aux5;
uint16_t aux6;
uint16_t aux7;
uint16_t aux8;
uint16_t aux9;
uint16_t aux10;
uint16_t aux11;
uint16_t aux12;
};
struct MSP_SET_RAW_GPS : public MSP_PACKET_SET{
MSP_SET_RAW_GPS()
{
message_id = 201;
message_length = 16;
}
uint8_t fix; // might be able to change this to bool
uint8_t num_sat;
uint32_t lattitude; // 1 / 10 000 000 degree
uint32_t longitude; // 1 / 10 000 000 degree
uint16_t altitude; // metre
uint16_t speed; // cm / s
uint16_t ground_course; // degree * 10
};
#endif