always show timing warning, not only when debugging is enabled
authorMichael Gernoth <michael@gernoth.net>
Sun, 7 Jul 2013 20:38:11 +0000 (22:38 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sun, 7 Jul 2013 20:38:11 +0000 (22:38 +0200)
hmcfgusb.c
hmland.c
hmsniff.c

index 5939dd6..77f977f 100644 (file)
@@ -183,8 +183,7 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len
        msec = ((tv_end.tv_sec-tv_start.tv_sec)*1000)+((tv_end.tv_usec-tv_start.tv_usec)/1000);
 
        if (msec > 100) {
-               if (debug)
-                       fprintf(stderr, "usb-transfer took more than 100ms (%dms), this can lead to timing problems!\n", msec);
+               fprintf(stderr, "usb-transfer took more than 100ms (%dms), this can lead to timing problems!\n", msec);
        } else if (debug) {
                fprintf(stderr, "usb-transfer took %dms!\n", msec);
        }
index 15b46ab..f963e2b 100644 (file)
--- a/hmland.c
+++ b/hmland.c
@@ -359,6 +359,7 @@ static int comm(int fd_in, int fd_out, int master_socket, int flags)
 
        memset(out, 0, sizeof(out));
        out[0] = 'K';
+       hmcfgusb_send_null_frame(dev);
        hmcfgusb_send(dev, out, sizeof(out), 1);
 
        while(!quit) {
@@ -558,7 +559,7 @@ static int socket_server(char *iface, int port, int flags)
                                        (client_addr & 0x0000ff00) >> 8,
                                        (client_addr & 0x000000ff));
                }
-
+               sleep(1);
        }
 
        return EXIT_SUCCESS;
index e842453..837f4e0 100644 (file)
--- a/hmsniff.c
+++ b/hmsniff.c
@@ -188,6 +188,7 @@ int main(int argc, char **argv)
                }
                printf("HM-CFG-USB opened!\n");
 
+               hmcfgusb_send_null_frame(dev);
                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
 
                while(!quit) {
@@ -199,7 +200,7 @@ int main(int argc, char **argv)
                                rdata.wrong_hmid = 0;
                                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
                        }
-                       fd = hmcfgusb_poll(dev, 10);
+                       fd = hmcfgusb_poll(dev, 1);
                        if (fd >= 0) {
                                fprintf(stderr, "activity on unknown fd %d!\n", fd);
                                continue;
@@ -207,6 +208,9 @@ int main(int argc, char **argv)
                                if (errno) {
                                        perror("hmcfgusb_poll");
                                        break;
+                               } else {
+                                       /* periodically wakeup the device */
+                                       hmcfgusb_send_null_frame(dev);
                                }
                        }
                }
Impressum, Datenschutz