40 #include <boost/function.hpp> 41 #include <boost/thread.hpp> 43 struct libusb_device_handle;
44 struct libusb_context;
53 std::runtime_error(msg), error_code_(code)
61 UsbDevice(uint16_t vid, uint16_t pid, uint8_t mi);
68 UsbIds(uint16_t _vid, uint16_t _pid) : vid(_vid), pid(_pid) {}
75 Location(uint8_t _bus, uint8_t _port = 0, uint8_t _addr = 0, uint16_t _vid = 0, uint16_t _pid = 0) : loc(0) {
89 return match(*
this, other);
92 return loc == other.
loc;
95 return loc != other.
loc;
98 return loc < other.
loc;
101 return loc > other.
loc;
104 return loc <= other.
loc;
107 return loc >= other.
loc;
121 static void listDevices(
const std::vector<UsbIds> &ids, std::vector<Location> &list);
122 static void listDevices(uint16_t vid, uint16_t pid, std::vector<Location> &list);
123 void listDevices(std::vector<Location> &list)
const;
125 void setDevceIds(uint16_t vid, uint16_t pid, uint8_t mi);
132 bool bulkWrite(
const void * data,
int size,
unsigned char endpoint,
int timeout);
133 int bulkRead(
void * data,
int size,
unsigned char endpoint,
int timeout);
134 bool interruptWrite(
const void * data,
int size,
unsigned char endpoint,
int timeout);
135 int interruptRead(
void * data,
int size,
unsigned char endpoint,
int timeout);
137 typedef boost::function<void(const void *data, int size)>
Callback;
138 void startBulkReadThread(Callback callback,
unsigned char endpoint);
139 void stopBulkReadThread(
unsigned char endpoint);
140 void startInterruptReadThread(Callback callback,
unsigned char endpoint);
141 void stopInterruptReadThread(
unsigned char endpoint);
144 int getLastError(std::string &str)
const;
145 void setDebugLevel(uint8_t level);
148 bool handleError(
int err);
149 void throwError(
int err);
153 void bulkReadThread(Callback callback,
unsigned char endpoint);
154 void interruptReadThread(Callback callback,
unsigned char endpoint);
166 boost::thread bulk_threads_[128];
167 bool bulk_threads_enable_[128];
168 boost::thread interrupt_threads_[128];
169 bool interrupt_threads_enable_[128];
bool operator==(const Location &other) const
bool operator<=(const Location &other) const
Location(uint8_t _bus, uint8_t _port=0, uint8_t _addr=0, uint16_t _vid=0, uint16_t _pid=0)
libusb_device_handle * libusb_handle_
bool operator<(const Location &other) const
static bool match(const Location &a, const Location &b)
bool operator!=(const Location &other) const
bool operator>(const Location &other) const
Location getLocation() const
bool operator>=(const Location &other) const
UsbDeviceException(int code, const char *msg)
boost::function< void(const void *data, int size)> Callback
UsbIds(uint16_t _vid, uint16_t _pid)
bool match(const Location &other) const