00001 #include <unistd.h> 00002 #include <stdlib.h> 00003 #include <stdio.h> 00004 #include <errno.h> 00005 #include <string> 00006 #include <libusb-1.0/libusb.h> 00007 00008 #define ACM_CTRL_DTR 0x01 00009 #define ACM_CTRL_RTS 0x02 00010 00011 namespace milvus 00012 { 00013 class UsbComm 00014 { 00015 public: 00017 UsbComm(); 00019 ~UsbComm(); 00020 00021 int open_device(uint16_t vendor_id, uint16_t product_id, int ep_in_addr, int ep_out_addr); 00022 int close_device(); 00023 int read_bytes(unsigned char *, int); 00024 int write_bytes(unsigned char *, int); 00025 00026 private: 00028 void print_array(uint8_t *buf, int length); 00029 00030 struct libusb_device_handle *devh; 00031 int ep_in_addr_; 00032 int ep_out_addr_; 00034 int baud_; 00035 std::string port_name_; 00036 int error; 00037 }; 00038 00039 }