-
Notifications
You must be signed in to change notification settings - Fork 5
/
usbops.hpp
29 lines (24 loc) · 850 Bytes
/
usbops.hpp
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
// USB操作
#ifndef _USB_OPS_HPP_
#define _USB_OPS_HPP_
#include <linux/version.h>
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 4, 20)
#include <usb.h>
#include <linux/usb.h>
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 21)
#include <linux/usb_ch9.h>
#else
#include <linux/usb/ch9.h>
#endif
#include <linux/usbdevice_fs.h>
//#include <string>
void usb_getdesc(const char *devfile, usb_device_descriptor* desc);
int usb_open(const char *devfile);
void usb_claim(int fd, unsigned int interface);
void usb_release(int fd, unsigned int interface);
int usb_setinterface(int fd, const unsigned int interface, const unsigned int altsetting);
int usb_ctrl(int fd, usbdevfs_ctrltransfer *ctrl);
int usb_submiturb(int fd, usbdevfs_urb* urbp);
int usb_reapurb_ndelay(int fd, usbdevfs_urb** urbpp);
int usb_discardurb(int fd, usbdevfs_urb* urbp);
#endif