ret = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR, 0xa0,
0xe600, 0x0000, buf, 1, 100);
if (ret < 0)
- sr_err("Unable to send control request: %d", ret);
+ sr_err("Unable to send control request: %s",
+ libusb_error_name(ret));
return ret;
}
LIBUSB_ENDPOINT_OUT, 0xa0, offset,
0x0000, buf, chunksize, 100);
if (ret < 0) {
- sr_err("Unable to send firmware to device: %d",
- ret);
+ sr_err("Unable to send firmware to device: %s",
+ libusb_error_name(ret));
result = SR_ERR;
break;
}
libusb_get_bus_number(dev), libusb_get_device_address(dev));
if ((ret = libusb_open(dev, &hdl)) < 0) {
- sr_err("failed to open device: %d", ret);
+ sr_err("ezusb: failed to open device: %s",
+ libusb_error_name(ret));
return SR_ERR;
}
#if !defined(_WIN32) && !defined(__APPLE__)
if (libusb_kernel_driver_active(hdl, 0)) {
if ((ret = libusb_detach_kernel_driver(hdl, 0)) < 0) {
- sr_err("failed to detach kernel driver: %d", ret);
+ sr_err("failed to detach kernel driver: %s",
+ libusb_error_name(ret));
return SR_ERR;
}
}
#endif
if ((ret = libusb_set_configuration(hdl, configuration)) < 0) {
- sr_err("Unable to set configuration: %d", ret);
+ sr_err("Unable to set configuration: %s",
+ libusb_error_name(ret));
return SR_ERR;
}
libusb_get_device_list(usb_ctx, &devlist);
for (i = 0; devlist[i]; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("Failed to get device descriptor: %d.", ret);
+ sr_err("Failed to get device descriptor: %s.",
+ libusb_error_name(ret));
continue;
}
(unsigned char *)vi, sizeof(struct version_info), 100);
if (ret < 0) {
- sr_err("fx2lafw: Unable to get version info: %d.", ret);
+ sr_err("fx2lafw: Unable to get version info: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
revid, 1, 100);
if (ret < 0) {
- sr_err("fx2lafw: Unable to get REVID: %d.", ret);
+ sr_err("fx2lafw: Unable to get REVID: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 100);
if (ret < 0) {
- sr_err("fx2lafw: Unable to send start command: %d.", ret);
+ sr_err("fx2lafw: Unable to send start command: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
for (i = 0; i < device_count; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("fx2lafw: Failed to get device descriptor: %d.",
- ret);
+ sr_err("fx2lafw: Failed to get device descriptor: %s.",
+ libusb_error_name(ret));
continue;
}
*/
devc->usb->address = libusb_get_device_address(devlist[i]);
} else {
- sr_err("fx2lafw: Failed to open device: %d.", ret);
+ sr_err("fx2lafw: Failed to open device: %s.",
+ libusb_error_name(ret));
break;
}
if ((ret = libusb_get_device_descriptor(
devlist[i], &des)) != 0) {
- sr_warn("fx2lafw: Failed to get device descriptor: %d.", ret);
+ sr_warn("fx2lafw: Failed to get device descriptor: %s.",
+ libusb_error_name(ret));
continue;
}
break;
default:
- sr_err("fx2lafw: Unable to claim interface: %d.", ret);
+ sr_err("fx2lafw: Unable to claim interface: %s.",
+ libusb_error_name(ret));
break;
}
static void resubmit_transfer(struct libusb_transfer *transfer)
{
- if (libusb_submit_transfer(transfer) != 0) {
- free_transfer(transfer);
- /* TODO: Stop session? */
- /* TODO: Better error message. */
- sr_err("fx2lafw: %s: libusb_submit_transfer error.", __func__);
- }
+ int ret = libusb_submit_transfer(transfer);
+
+ if (LIBUSB_SUCCESS == ret)
+ return;
+
+ free_transfer(transfer);
+ /* TODO: Stop session? */
+
+ sr_err("fx2lafw: %s: %s", __func__, libusb_error_name(ret));
}
static void receive_transfer(struct libusb_transfer *transfer)
libusb_fill_bulk_transfer(transfer, devc->usb->devhdl,
2 | LIBUSB_ENDPOINT_IN, buf, size,
receive_transfer, devc, timeout);
- if (libusb_submit_transfer(transfer) != 0) {
+ if ((ret = libusb_submit_transfer(transfer)) != 0) {
+ sr_err("fx2lafw: %s: libusb_submit_transfer: %s.",
+ __func__, libusb_error_name(ret));
libusb_free_transfer(transfer);
g_free(buf);
abort_acquisition(devc);
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("Failed to get device descriptor: %d.", ret);
+ sr_err("Failed to get device descriptor: %s.",
+ libusb_error_name(ret));
continue;
}
err = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE);
if (err != 0) {
- sr_err("Unable to claim interface: %d.", err);
+ sr_err("Unable to claim interface: %s.",
+ libusb_error_name(err));
return SR_ERR;
}
if ((ret = libusb_control_transfer(devc->usb->devhdl,
LIBUSB_REQUEST_TYPE_VENDOR, CTRL_BEGINCOMMAND,
0, 0, buffer, sizeof(buffer), 200)) != sizeof(buffer)) {
- sr_err("Failed to send begincommand: %d.", ret);
+ sr_err("Failed to send begincommand: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) {
if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("Failed to get device descriptor: %d.", err);
+ sr_err("Failed to get device descriptor: %s.",
+ libusb_error_name(err));
continue;
}
devc->usb->address, USB_INTERFACE);
}
} else {
- sr_err("Failed to open device: %d.", err);
+ sr_err("Failed to open device: %s.",
+ libusb_error_name(err));
}
/* If we made it here, we handled the device (somehow). */
(unsigned char *)&devc->channel_levels,
sizeof(devc->channel_levels), 200);
if (ret != sizeof(devc->channel_levels)) {
- sr_err("Failed to get channel offsets: %d.", ret);
+ sr_err("Failed to get channel offsets: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) {
- sr_err("Failed to set trigger/samplerate: %d.", ret);
+ sr_err("Failed to set trigger/samplerate: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Sent CMD_SET_TRIGGER_SAMPLERATE.");
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) {
- sr_err("Failed to set filters: %d", ret);
+ sr_err("Failed to set filters: %s",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Sent CMD_SET_FILTERS.");
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) {
- sr_err("Failed to set voltage: %d.", ret);
+ sr_err("Failed to set voltage: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Sent CMD_SET_VOLTAGE.");
if ((ret = libusb_control_transfer(devc->usb->devhdl,
LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETRELAYS,
0, 0, relays, 17, 100)) != sizeof(relays)) {
- sr_err("Failed to set relays: %d.", ret);
+ sr_err("Failed to set relays: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Sent CTRL_SETRELAYS.");
if ((ret = libusb_control_transfer(devc->usb->devhdl,
LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETOFFSET,
0, 0, offsets, sizeof(offsets), 100)) != sizeof(offsets)) {
- sr_err("Failed to set offsets: %d.", ret);
+ sr_err("Failed to set offsets: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Sent CTRL_SETOFFSET.");
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) {
- sr_err("Failed to enable trigger: %d.", ret);
+ sr_err("Failed to enable trigger: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) {
- sr_err("Failed to force trigger: %d.", ret);
+ sr_err("Failed to force trigger: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
cmdstring[1] = 0;
if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
- sr_dbg("Failed to send get_capturestate command: %d.", ret);
+ sr_dbg("Failed to send get_capturestate command: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
if ((ret = libusb_bulk_transfer(devc->usb->devhdl,
DSO_EP_IN | LIBUSB_ENDPOINT_IN,
inbuf, 512, &tmp, 100)) != 0) {
- sr_dbg("Failed to get capturestate: %d.", ret);
+ sr_dbg("Failed to get capturestate: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
*capturestate = inbuf[0];
cmdstring[1] = 0;
if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
- sr_err("Failed to send capture_start command: %d.", ret);
+ sr_err("Failed to send capture_start command: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
cmdstring[1] = 0;
if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
- sr_err("Failed to get channel data: %d.", ret);
+ sr_err("Failed to get channel data: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
DSO_EP_IN | LIBUSB_ENDPOINT_IN, buf,
devc->epin_maxpacketsize, cb, devc, 40);
if ((ret = libusb_submit_transfer(transfer)) != 0) {
- sr_err("Failed to submit transfer: %d.", ret);
+ sr_err("Failed to submit transfer: %s.",
+ libusb_error_name(ret));
/* TODO: Free them all. */
libusb_free_transfer(transfer);
g_free(buf);
if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0);
if (ret < 0) {
- sr_err("Failed to detach kernel driver: %d.", ret);
+ sr_err("Failed to detach kernel driver: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Successfully detached kernel driver.");
/* Claim interface 0. */
if ((ret = libusb_claim_interface(devc->usb->devhdl, 0)) < 0) {
- sr_err("Failed to claim interface 0: %d.", ret);
+ sr_err("Failed to claim interface 0: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Successfully claimed interface 0.");
1000 /* timeout (ms) */);
if (ret < 0) {
- sr_err("HID feature report error: %d.", ret);
+ sr_err("HID feature report error: %s.", libusb_error_name(ret));
return SR_ERR;
}
1000 /* timeout (ms) */);
if (ret < 0) {
- sr_err("USB receive error: %d.", ret);
+ sr_err("USB receive error: %s.", libusb_error_name(ret));
return FALSE;
}
/* The device reports as HID class, so the kernel would have
* claimed it. */
if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
- if (libusb_detach_kernel_driver(devc->usb->devhdl, 0) < 0) {
- sr_err("Failed to detach kernel driver.");
+ if ((ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0)) < 0) {
+ sr_err("Failed to detach kernel driver: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
}
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEADDR,
0, packet, 1, TIMEOUT);
if (ret != 1)
- sr_err("zp: %s: libusb_control_transfer returned %d.",
- __func__, ret);
+ sr_err("zp: %s: %s.", __func__, libusb_error_name(ret));
return ret;
}
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEDATA,
0, packet, 1, TIMEOUT);
if (ret != 1)
- sr_err("zp: %s: libusb_control_transfer returned %d.",
- __func__, ret);
+ sr_err("zp: %s: %s.", __func__, libusb_error_name(ret));
return ret;
}
ret = libusb_control_transfer(devh, CTRL_IN, 0xc, REQ_READDATA,
0, packet, 1, TIMEOUT);
if (ret != 1)
- sr_err("zp: %s: libusb_control_transfer returned %d, "
- "val=%hhx.", __func__, ret, packet[0]);
+ sr_err("zp: %s: %s, val=%hhx.", __func__,
+ libusb_error_name(ret), packet[0]);
return (ret == 1) ? packet[0] : ret;
}
ret = libusb_control_transfer(devh, CTRL_OUT, 0x4, REQ_READBULK,
0, packet, 8, TIMEOUT);
if (ret != 8)
- sr_err("zp: %s: libusb_control_transfer returned %d.",
- __func__, ret);
+ sr_err("zp: %s: libusb_control_transfer: %s.", __func__,
+ libusb_error_name(ret));
ret = libusb_bulk_transfer(devh, EP1_BULK_IN, buffer, size,
&transferred, TIMEOUT);
if (ret < 0)
- sr_err("zp: Bulk read error %d.", ret);
+ sr_err("zp: %s: libusb_bulk_transfer: %s.", __func__,
+ libusb_error_name(ret));
return transferred;
}
for (i = 0; devlist[i]; i++) {
ret = libusb_get_device_descriptor(devlist[i], &des);
if (ret != 0) {
- sr_err("zp: failed to get device descriptor: %d", ret);
+ sr_err("zp: failed to get device descriptor: %s",
+ libusb_error_name(ret));
continue;
}
dev = NULL;
for (i = 0; i < device_count; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("fx2lafw: Failed to get device descriptor: %d.",
- ret);
+ sr_err("zp: Failed to get device descriptor: %s.",
+ libusb_error_name(ret));
continue;
}
if (libusb_get_bus_number(devlist[i]) == devc->usb->bus
sdi->index, devc->usb->bus,
devc->usb->address, USB_INTERFACE);
} else {
- sr_err("zp: failed to open device: %d", ret);
+ sr_err("zp: failed to open device: %s", libusb_error_name(ret));
return SR_ERR;
}
ret = libusb_set_configuration(devc->usb->devhdl, USB_CONFIGURATION);
if (ret < 0) {
- sr_err("zp: Unable to set USB configuration %d: %d",
- USB_CONFIGURATION, ret);
+ sr_err("zp: Unable to set USB configuration %d: %s",
+ USB_CONFIGURATION, libusb_error_name(ret));
return SR_ERR;
}
ret = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE);
if (ret != 0) {
- sr_err("zp: Unable to claim interface: %d", ret);
+ sr_err("zp: Unable to claim interface: %s",
+ libusb_error_name(ret));
return SR_ERR;
}