SeaBreeze
USB.h
Go to the documentation of this file.
1 /***************************************************/
30 #ifndef SEABREEZE_USB_H
31 #define SEABREEZE_USB_H
32 
34 #include "native/usb/NativeUSB.h"
35 #include <string>
36 
37 namespace seabreeze {
38 
39  /* Empty declaration of USBDiscovery to deal with cross-includes */
40  class USBDiscovery;
41 
42  class USB {
43  public:
44  virtual ~USB();
45 
46  bool open();
47  bool close();
48  int write(int endpoint, void *data, unsigned int length_bytes);
49  int read(int endpoint, void *data, unsigned int length_bytes);
50  void clearStall(int endpoint);
51 
52  static void setVerbose(bool v);
53 
54  int getDeviceDescriptor(struct USBDeviceDescriptor *desc);
55  int getInterfaceDescriptor(struct USBInterfaceDescriptor *desc);
56  /* Get the endpoint descriptor where index is the endpoint index. */
57  int getEndpointDescriptor(int index, struct USBEndpointDescriptor *epDesc);
58  std::string *getStringDescriptor(int index);
59  int getMaxPacketSize();
60 
61  bool isOpened();
62 
63  /* This allows the USBDiscovery class to access the protected
64  * constructor and act as a factory for USB instances.
65  */
66  friend class USBDiscovery;
67 
68  protected:
69 
70  /* These methods are primarily for debugging. */
71  void usbHexDump(void *x, int length, int endpoint);
72  void hexDump(void *x, int length);
73  void describeTransfer(const char *label, int length, void* data, int endpoint, bool hexdump);
74  USB(unsigned long deviceID);
75 
76  void *descriptor;
77  bool opened;
78  static bool verbose;
79  unsigned long deviceID;
80  };
81 
82 }
83 
84 #endif
Definition: NativeUSB.h:97
Definition: NativeUSB.h:68
Definition: USB.h:42
Encapsulates all SeaBreeze classes.
Definition: DeviceFactory.h:42
Definition: USBDiscovery.h:40
Definition: NativeUSB.h:85