#include <sys/time.h>
#include <libusb-1.0/libusb.h>
+/* Workaround for old libusb-1.0 */
+#ifndef LIBUSB_CALL
+#define LIBUSB_CALL
+#define libusb_handle_events_timeout_completed(ctx, tv, x) libusb_handle_events_timeout(ctx, tv)
+#endif
+
#include "hexdump.h"
#include "hmcfgusb.h"
memset(out, 0, sizeof(out));
- err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, out, sizeof(out), &cnt, USB_TIMEOUT);
+ err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, out, 0, &cnt, USB_TIMEOUT);
if (err && (!silent)) {
fprintf(stderr, "Can't send null frame: %s\n", usb_strerror(err));
return 0;
{
struct timeval tv;
int usb_event = 0;
+ int timed_out = 0;
int i;
int n;
int fd_n;
return -1;
} else if (n == 0) {
usb_event = 1;
+ timed_out = 1;
} else {
for (fd_n = 0; fd_n < dev->n_pfd; fd_n++) {
if (dev->pfd[fd_n].revents) {
errno = quit;
}
+ if (timed_out)
+ errno = ETIMEDOUT;
+
return -1;
}