#define INTERFACE 0
static int quit = 0;
+static int debug = 0;
/* Not in all libusb-1.0 versions, so we have to roll our own :-( */
static char * usb_strerror(int e)
{
int err;
int cnt;
- int ret;
+ if (debug)
+ hexdump(send_data, len, "USB < ");
err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, send_data, len, &cnt, USB_TIMEOUT);
if (err) {
fprintf(stderr, "Can't send data: %s\n", usb_strerror(err));
- if (err == LIBUSB_ERROR_NO_DEVICE)
- exit(EXIT_FAILURE);
return 0;
}
err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, send_data, 0, &cnt, USB_TIMEOUT);
if (err) {
fprintf(stderr, "Can't send data: %s\n", usb_strerror(err));
- if (err == LIBUSB_ERROR_NO_DEVICE)
- exit(EXIT_FAILURE);
return 0;
}
}
- return ret;
+ return 1;
}
static struct libusb_transfer *hmcfgusb_prepare_int(libusb_device_handle *devh, libusb_transfer_cb_fn cb, void *data)
}
} else {
if (cb_data && cb_data->cb) {
+ if (debug)
+ hexdump(transfer->buffer, transfer->actual_length, "USB > ");
cb_data->cb(transfer->buffer, transfer->actual_length, cb_data->data);
} else {
- hexdump(transfer->buffer, transfer->actual_length, "RECV> ");
+ hexdump(transfer->buffer, transfer->actual_length, "> ");
}
}
}
libusb_close(dev->usb_devh);
+ free(dev->pfd);
free(dev);
libusb_exit(NULL);
}
+
+void hmcfgusb_set_debug(int d)
+{
+ debug = d;
+}