do not report errors when sending of the wakeup-frame fails
authorMichael Gernoth <michael@gernoth.net>
Sat, 13 Jul 2013 13:52:21 +0000 (15:52 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sat, 13 Jul 2013 13:52:21 +0000 (15:52 +0200)
hmcfgusb.c
hmcfgusb.h
hmland.c
hmsniff.c

index 05f16be..825b313 100644 (file)
@@ -142,14 +142,14 @@ static libusb_device_handle *hmcfgusb_find() {
        return NULL;
 }
 
-int hmcfgusb_send_null_frame(struct hmcfgusb_dev *usbdev)
+int hmcfgusb_send_null_frame(struct hmcfgusb_dev *usbdev, int silent)
 {
        int err;
        int cnt;
 
        err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, NULL, 0, &cnt, USB_TIMEOUT);
-       if (err) {
-               fprintf(stderr, "Can't send data: %s\n", usb_strerror(err));
+       if (err && (!silent)) {
+               fprintf(stderr, "Can't send null frame: %s\n", usb_strerror(err));
                return 0;
        }
 
@@ -176,7 +176,7 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len
        }
 
        if (done) {
-               if (!hmcfgusb_send_null_frame(usbdev)) {
+               if (!hmcfgusb_send_null_frame(usbdev, 0)) {
                        return 0;
                }
        }
index e50f831..df6d1c1 100644 (file)
@@ -32,7 +32,7 @@ struct hmcfgusb_dev {
 };
 
 int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len, int done);
-int hmcfgusb_send_null_frame(struct hmcfgusb_dev *usbdev);
+int hmcfgusb_send_null_frame(struct hmcfgusb_dev *usbdev, int silent);
 struct hmcfgusb_dev *hmcfgusb_init(hmcfgusb_cb_fn cb, void *data);
 int hmcfgusb_add_pfd(struct hmcfgusb_dev *dev, int fd, short events);
 int hmcfgusb_poll(struct hmcfgusb_dev *dev, int timeout);
index a9d9670..c50022c 100644 (file)
--- a/hmland.c
+++ b/hmland.c
@@ -455,7 +455,7 @@ static int comm(int fd_in, int fd_out, int master_socket, int flags)
        memset(out, 0, sizeof(out));
        out[0] = 'K';
        wait_for_h = 1;
-       hmcfgusb_send_null_frame(dev);
+       hmcfgusb_send_null_frame(dev, 1);
        hmcfgusb_send(dev, out, sizeof(out), 1);
 
        while(!quit) {
@@ -482,7 +482,7 @@ static int comm(int fd_in, int fd_out, int master_socket, int flags)
                                quit = 1;
                        } else {
                                /* periodically wakeup the device */
-                               hmcfgusb_send_null_frame(dev);
+                               hmcfgusb_send_null_frame(dev, 1);
                        }
                }
        }
index 837f4e0..1936d5b 100644 (file)
--- a/hmsniff.c
+++ b/hmsniff.c
@@ -188,7 +188,7 @@ int main(int argc, char **argv)
                }
                printf("HM-CFG-USB opened!\n");
 
-               hmcfgusb_send_null_frame(dev);
+               hmcfgusb_send_null_frame(dev, 1);
                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
 
                while(!quit) {
@@ -210,7 +210,7 @@ int main(int argc, char **argv)
                                        break;
                                } else {
                                        /* periodically wakeup the device */
-                                       hmcfgusb_send_null_frame(dev);
+                                       hmcfgusb_send_null_frame(dev, 1);
                                }
                        }
                }
Impressum, Datenschutz