int cnt;
if (debug)
- hexdump(send_data, len, "< ");
+ 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 != 0) {
fprintf(stderr, "Can't submit transfer: %s\n", usb_strerror(err));
libusb_free_transfer(transfer);
- free(data_buf);
return NULL;
}
} else {
if (cb_data && cb_data->cb) {
if (debug)
- hexdump(transfer->buffer, transfer->actual_length, "> ");
+ 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, "> ");
dev->n_pfd = dev->n_usb_pfd;
+ quit = 0;
+
return dev;
}
n = poll(dev->pfd, dev->n_pfd, tv.tv_sec * 1000);
if (n < 0) {
perror("poll");
+ errno = 0;
return -1;
} else if (n == 0) {
usb_event = 1;
usb_event = 1;
break;
} else {
+ errno = 0;
return dev->pfd[fd_n].fd;
}
}
}
}
- if (quit)
+ errno = 0;
+ if (quit) {
+ fprintf(stderr, "closing device-connection due to error %d\n", quit);
errno = quit;
+ }
return -1;
}