]> git.zerfleddert.de Git - hmcfgusb/blobdiff - hmcfgusb.c
revert null frame to zero length
[hmcfgusb] / hmcfgusb.c
index 825b3132a3bbc660d37ef6a41259fbc7b785d6e7..6df2bcaa327ed19576ec6fb4667cece08ec568ed 100644 (file)
@@ -146,8 +146,11 @@ int hmcfgusb_send_null_frame(struct hmcfgusb_dev *usbdev, int silent)
 {
        int err;
        int cnt;
+       unsigned char out[0x40];
 
-       err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, NULL, 0, &cnt, USB_TIMEOUT);
+       memset(out, 0, sizeof(out));
+
+       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;
@@ -242,7 +245,7 @@ static void LIBUSB_CALL hmcfgusb_interrupt(struct libusb_transfer *transfer)
 
        if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
                if (transfer->status != LIBUSB_TRANSFER_TIMED_OUT) {
-                       fprintf(stderr, "Interrupt transfer not completed: %d!\n", transfer->status);
+                       fprintf(stderr, "Interrupt transfer not completed: %s!\n", usb_strerror(transfer->status));
                        quit = EIO;
 
                        if (cb_data && cb_data->dev && cb_data->dev->transfer) {
@@ -390,6 +393,7 @@ int hmcfgusb_poll(struct hmcfgusb_dev *dev, int timeout)
 {
        struct timeval tv;
        int usb_event = 0;
+       int timed_out = 0;
        int i;
        int n;
        int fd_n;
@@ -427,6 +431,7 @@ int hmcfgusb_poll(struct hmcfgusb_dev *dev, int timeout)
                        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) {
@@ -458,6 +463,9 @@ int hmcfgusb_poll(struct hmcfgusb_dev *dev, int timeout)
                errno = quit;
        }
 
+       if (timed_out)
+               errno = ETIMEDOUT;
+
        return -1;
 }
 
Impressum, Datenschutz