dji_type.hpp
Go to the documentation of this file.
1 
32 #ifndef DJI_TYPE
33 #define DJI_TYPE
34 
35 #include <cstdio>
36 #include <stdint.h>
37 
39 #ifdef __GNUC__
40 #define __UNUSED __attribute__((__unused__))
41 #define __DELETE(x) delete (char*)x
42 #else
43 #define __UNUSED
44 #define __DELETE(x) delete x
45 
47 #ifndef STM32
48 #pragma warning(disable : 4100)
49 #pragma warning(disable : 4800)
50 #pragma warning(disable : 4996)
51 #pragma warning(disable : 4244)
52 #pragma warning(disable : 4267)
53 #pragma warning(disable : 4700)
54 #pragma warning(disable : 4101)
55 #endif // STM32
56 #endif //__GNUC__
57 
58 #ifdef WIN32
59 #define __func__ __FUNCTION__
60 #endif // WIN32
61 
63 #ifdef ARMCC
64 #pragma anon_unions
65 #endif
66 
67 #ifdef STM32
68 typedef unsigned int size_t;
69 #endif
70 
71 namespace DJI {
72 namespace OSDK {
73 
75 typedef void *UserData;
76 
77 typedef uint64_t time_ms;
78 typedef uint64_t time_us; // about 0.3 million years
79 
80 typedef float float32_t;
81 typedef double float64_t;
82 
83 extern char buffer[];
84 
85 /******************Protocol Related Definitions***************************/
86 
87 const size_t SESSION_TABLE_NUM = 32;
88 const size_t CALLBACK_LIST_NUM = 10;
89 
93 const size_t MAX_INCOMING_DATA_SIZE = 300;
94 const size_t MAX_ACK_SIZE = 107;
95 
99 static const uint8_t CAMERA_PAIR_NUM = 5;
100 static const uint8_t IMAGE_TYPE_NUM = 10;
101 
103 typedef struct OpenHeader {
104  uint32_t sof : 8;
105  uint32_t length : 10;
106  uint32_t version : 6;
107  uint32_t sessionID : 5;
108  uint32_t isAck : 1;
109  uint32_t reserved0 : 2; // always 0
110  uint32_t padding : 5;
111  uint32_t enc : 3;
112  uint32_t reserved1 : 24;
113  uint32_t sequenceNumber : 16;
114  uint32_t crc : 16;
115 } OpenHeader;
116 
117 typedef struct Command {
118  uint16_t sessionMode : 2;
119  uint16_t encrypt : 1;
120  uint16_t retry : 13;
121  uint16_t timeout; // unit is ms
122  size_t length;
123  uint8_t *buf;
124  uint8_t cmd_set;
125  uint8_t cmd_id;
126  bool isCallback;
127  int callbackID;
128 } Command;
129 
130 typedef struct MMU_Tab {
131  uint32_t tabIndex : 8;
132  uint32_t usageFlag : 8;
133  uint32_t memSize : 16;
134  uint8_t *pmem;
135 } MMU_Tab;
136 
137 typedef struct CMDSession {
138  uint8_t cmd_set;
139  uint8_t cmd_id;
140  uint8_t *buf;
141 
142  uint32_t sessionID : 5;
143  uint32_t usageFlag : 1;
144  uint32_t sent : 5;
145  uint32_t retry : 5;
146  uint32_t timeout : 16;
147  MMU_Tab *mmu;
148  bool isCallback;
149  int callbackID;
150  uint32_t preSeqNum;
151  time_ms preTimestamp;
152 } CMDSession;
153 
154 typedef struct ACKSession {
155  uint32_t sessionID : 5;
156  uint32_t sessionStatus : 2;
157  uint32_t res : 25;
158  MMU_Tab *mmu;
159 } ACKSession;
160 
161 const uint8_t MAX_OSDK_VERSION_SIZE = 16;
162 const uint8_t MAX_SEND_DATA_BURY_PKG_COUNT = 5;
163 #pragma pack(1)
164 typedef struct DataBuryPack {
165  char sdk_version[MAX_OSDK_VERSION_SIZE];
166  uint8_t is_debug : 2;
167  uint8_t hardware_type : 3;
168  uint8_t operator_type : 3;
169 } DataBuryPack;
170 #pragma pack()
171 
172 enum OSDK_HARDWARE_TYPE{
173  UNKNOWN_HARDWARE_TYPE = 0,
174  ARMV7_HARDWARE_TYPE = 1,
175  ARMV8_HARDWARE_TYPE = 2,
176  x86_HARDWARE_TYPE = 3,
177  STM32_HARDWARE_TYPE = 4,
178 };
179 
180 enum OSDK_OPERATOR_TYPE{
181  UNKNOWN_OPERATOR_TYPE = 0,
182  LINUX_OPERATOR_TYPE = 1,
183  RTOS_OPERATOR_TYPE = 2,
184  ROS_OPERATOR_TYPE = 3,
185 };
186 
187 #pragma pack(1)
188 typedef struct HeartBeatPack {
189  uint8_t deviceID;
190  uint8_t linkID;
191  uint32_t seqNumber;
192  uint8_t data[8];
193 } HeartBeatPack;
194 #pragma pack()
195 
198 typedef struct VirtualRCSetting {
199  uint8_t enable : 1;
200  uint8_t cutoff : 1;
201  uint8_t reserved : 6;
203 
207 typedef struct VirtualRCData {
211  uint32_t roll;
212  uint32_t pitch;
213  uint32_t throttle;
214  uint32_t yaw;
215  uint32_t gear;
216  uint32_t reserved;
217  uint32_t mode;
218  uint32_t Channel_07;
219  uint32_t Channel_08;
220  uint32_t Channel_09;
221  uint32_t Channel_10;
222  uint32_t Channel_11;
223  uint32_t Channel_12;
224  uint32_t Channel_13;
225  uint32_t Channel_14;
226  uint32_t Channel_15;
227 } VirtualRCData;
228 
229 enum DJI_CAMERA_TAKE_PHOTO_TYPE {
230  DJI_CAMERA_TAKE_PHOTO_TYPE_STOP = 0,
231  DJI_CAMERA_TAKE_PHOTO_TYPE_NORMAL = 1,
232  DJI_CAMERA_TAKE_PHOTO_TYPE_HDR = 2,
233  DJI_CAMERA_TAKE_PHOTO_TYPE_BOKEH = 3,
234  DJI_CAMERA_TAKE_PHOTO_TYPE_BURST = 4,
235  DJI_CAMERA_TAKE_PHOTO_TYPE_AEB = 5,
236  DJI_CAMERA_TAKE_PHOTO_TYPE_TIME_LAPSE = 6,
237  DJI_CAMERA_TAKE_PHOTO_TYPE_PANO_APP = 7,
238  DJI_CAMERA_TAKE_PHOTO_TYPE_TRACKING = 8,
239  DJI_CAMERA_TAKE_PHOTO_TYPE_RAW_BURST = 9,
240  DJI_CAMERA_TAKE_PHOTO_TYPE_EHDR = 10,
241 };
242 
243 enum DJI_CAMERA_TAKE_PHOTO_PROFILE {
244  DJI_CAMERA_MODE_PROFILE_PHOTO_NORMAL = 5, // Simple
245  DJI_CAMERA_MODE_PROFILE_PHOTO_INTERVAL = 8, // Timing mode
246  DJI_CAMERA_MODE_PROFILE_PHOTO_REGIONAL_SR = 22, //Regional super resolution photographing
247 };
248 
263 };
264 
265 enum DJI_CAMERA_RECORDING_TYPE {
266  DJI_CAMERA_RECORDING_TYPE_COMMON = 0,
267  DJI_CAMERA_RECORDING_TYPE_DELAY = 1,
268  DJI_CAMERA_RECORDING_TYPE_SLOW_MOTION = 2,
269  DJI_CAMERA_RECORDING_TYPE_QUICK_MOVIE = 3,
270  DJI_CAMERA_RECORDING_TYPE_TIMELAPSE_STATIONARY = 4,
271  DJI_CAMERA_RECORDING_TYPE_TIMELAPSE_MOTION = 5,
272  DJI_CAMERA_RECORDING_TYPE_TIMELAPSE_HYPER = 6,
273  DJI_CAMERA_RECORDING_TYPE_FAST_MOTION = 7,
274  DJI_CAMERA_RECORDING_TYPE_EMERGENCY_VIDEO = 8,
275  DJI_CAMERA_RECORDING_TYPE_HYPERLAPSE = 9,
276  DJI_CAMERA_RECORDING_TYPE_MARK_VIDEO = 10,
277 };
278 
279 enum DJI_CAMERA_RECORDING_CONTROL {
280  DJI_CAMERA_RECORDING_CONTROL_STOP = 0,
281  DJI_CAMERA_RECORDING_CONTROL_BEGIN = 1,
282  DJI_CAMERA_RECORDING_CONTROL_PAUSE = 2,
283  DJI_CAMERA_RECORDING_CONTROL_RESUME = 3,
284 };
285 
286 
287 } // namespace OSDK
288 } // namespace DJI
289 
290 #endif // DJI_TYPE
Definition: dji_type.hpp:256
Definition: dji_type.hpp:258
void * UserData
This is used as the datatype for all data arguments in callbacks.
Definition: dji_type.hpp:75
Definition: dji_type.hpp:260
Definition: dji_type.hpp:255
static const uint8_t CAMERA_PAIR_NUM
Definition: dji_type.hpp:99
The Header struct is meant to handle the open protocol header.
Definition: dji_type.hpp:103
Definition: dji_type.hpp:253
Definition: dji_type.hpp:252
Virtual RC Settings (supported only on Matrice 100)
Definition: dji_type.hpp:198
Definition: dji_type.hpp:254
Definition: dji_type.hpp:250
Definition: dji_type.hpp:261
Definition: dji_type.hpp:259
struct DJI::OSDK::VirtualRCData VirtualRCData
Virtual RC data (supported only on Matrice 100)
Definition: dji_type.hpp:257
struct DJI::OSDK::VirtualRCSetting VirtualRCSetting
Virtual RC Settings (supported only on Matrice 100)
Virtual RC data (supported only on Matrice 100)
Definition: dji_type.hpp:207
Definition: dji_ack.cpp:38
struct DJI::OSDK::OpenHeader OpenHeader
The Header struct is meant to handle the open protocol header.
Definition: dji_type.hpp:262
DJI_CAMERA_ISO_PARAMETER
Definition: dji_type.hpp:249
uint32_t roll
Definition: dji_type.hpp:211
const size_t MAX_INCOMING_DATA_SIZE
Definition: dji_type.hpp:93