DJI Onboard SDK  4.0
linux_usb_device.hpp
Go to the documentation of this file.
1 
12 #ifndef ONBOARDSDK_LINUX_USB_DEVICE_H
13 #define ONBOARDSDK_LINUX_USB_DEVICE_H
14 
15 #include <cstring>
16 #include <fcntl.h>
17 #include <termios.h>
18 #include <unistd.h>
19 #include <libusb.h>
20 
21 #include "dji_hard_driver.hpp"
22 
23 
24 namespace DJI
25 {
26 
27 namespace OSDK
28 {
29 
33 class LinuxUSBDevice : public HardDriver
34 {
35  static const int POSSIBLE_DJI_DEVICE_NUM = 6;
36  static const int TIMEOUT = 50;
37  static const int OUT_END_PT = 0x0A;
38  static const int IN_END_PT = 0x84;
39 
40  typedef struct USBFilter
41  {
42  uint16_t vid;
43  uint16_t pid;
44  } USBFilter;
45 
46 
47 public:
48 // static const int BUFFER_SIZE = 2048;
49 
50 public:
51 // LinuxUSBDevice(const char* device, uint32_t baudrate);
53  ~LinuxUSBDevice();
54 
55  void init();
56  bool isDJIUSBDevice(uint16_t idVendor, uint16_t idProduct);
57 
59  size_t send(const uint8_t* buf, size_t len);
60  size_t readall(uint8_t* buf, size_t maxlen);
61 
62  time_ms getTimeStamp();
63 private:
64  libusb_device* DJI_device;
65  libusb_device_handle* DJI_dev_handle;
66  int DJI_device_product_id;
67  USBFilter DJI_usb_dev_filter[POSSIBLE_DJI_DEVICE_NUM];
68 
69  bool deviceStatus;
70  bool foundDJIDevice;
71 };
72 }
73 }
74 
75 
76 #endif //ONBOARDSDK_LINUX_USB_DEVICE_H
size_t send(const uint8_t *buf, size_t len)
Start of DJI_HardDriver virtual function implementations.
Serial device driver abstraction. Provided as an abstract class. Please inherit and implement for ind...
handle array of characters
Definition: commondatarangehandler.h:14
POSIX-Compatible USB Driver for *NIX platforms.
Definition: linux_usb_device.hpp:33