From: Michael Gernoth Date: Sat, 13 Jul 2013 13:52:21 +0000 (+0200) Subject: do not report errors when sending of the wakeup-frame fails X-Git-Tag: v0.100~60 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/hmcfgusb/commitdiff_plain/6262005e88c7c9edff4c0f962ca338ffb2a299fb?ds=sidebyside do not report errors when sending of the wakeup-frame fails --- diff --git a/hmcfgusb.c b/hmcfgusb.c index 05f16be..825b313 100644 --- a/hmcfgusb.c +++ b/hmcfgusb.c @@ -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; } } diff --git a/hmcfgusb.h b/hmcfgusb.h index e50f831..df6d1c1 100644 --- a/hmcfgusb.h +++ b/hmcfgusb.h @@ -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); diff --git a/hmland.c b/hmland.c index a9d9670..c50022c 100644 --- 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); } } } diff --git a/hmsniff.c b/hmsniff.c index 837f4e0..1936d5b 100644 --- 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); } } }