]> git.zerfleddert.de Git - hmcfgusb/blobdiff - hmsniff.c
debian: make hmland configurable, update version
[hmcfgusb] / hmsniff.c
index 837f4e01e4f209d88d10efbefb0aa0dc52a93b8b..1f5d889a0fff7f7874f07ab54317beb847336a72 100644 (file)
--- a/hmsniff.c
+++ b/hmsniff.c
@@ -32,6 +32,7 @@
 #include <sys/time.h>
 #include <libusb-1.0/libusb.h>
 
 #include <sys/time.h>
 #include <libusb-1.0/libusb.h>
 
+#include "version.h"
 #include "hexdump.h"
 #include "hmcfgusb.h"
 
 #include "hexdump.h"
 #include "hmcfgusb.h"
 
@@ -124,7 +125,7 @@ static void dissect_hm(uint8_t *buf, int len)
        if (buf[2] & (1 << 7)) printf("RPTEN ");
        printf("\n");
        printf("\tMessage type: %s (0x%02x)\n", hm_message_types(buf[3]), buf[3]);
        if (buf[2] & (1 << 7)) printf("RPTEN ");
        printf("\n");
        printf("\tMessage type: %s (0x%02x)\n", hm_message_types(buf[3]), buf[3]);
-       printf("\tMesage: ");
+       printf("\tMessage: ");
        for (i = 10; i < len; i++) {
                printf("%02X", buf[i]);
        }
        for (i = 10; i < len; i++) {
                printf("%02X", buf[i]);
        }
@@ -188,7 +189,7 @@ int main(int argc, char **argv)
                }
                printf("HM-CFG-USB opened!\n");
 
                }
                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) {
                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
 
                while(!quit) {
@@ -200,17 +201,19 @@ int main(int argc, char **argv)
                                rdata.wrong_hmid = 0;
                                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
                        }
                                rdata.wrong_hmid = 0;
                                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
                        }
-                       fd = hmcfgusb_poll(dev, 1);
+                       fd = hmcfgusb_poll(dev, 1000);
                        if (fd >= 0) {
                                fprintf(stderr, "activity on unknown fd %d!\n", fd);
                                continue;
                        } else if (fd == -1) {
                                if (errno) {
                        if (fd >= 0) {
                                fprintf(stderr, "activity on unknown fd %d!\n", fd);
                                continue;
                        } else if (fd == -1) {
                                if (errno) {
-                                       perror("hmcfgusb_poll");
-                                       break;
-                               } else {
-                                       /* periodically wakeup the device */
-                                       hmcfgusb_send_null_frame(dev);
+                                       if (errno != ETIMEDOUT) {
+                                               perror("hmcfgusb_poll");
+                                               break;
+                                       } else {
+                                               /* periodically wakeup the device */
+                                               hmcfgusb_send_null_frame(dev, 1);
+                                       }
                                }
                        }
                }
                                }
                        }
                }
@@ -218,5 +221,7 @@ int main(int argc, char **argv)
                hmcfgusb_close(dev);
        } while (!quit);
 
                hmcfgusb_close(dev);
        } while (!quit);
 
+       hmcfgusb_exit();
+
        return EXIT_SUCCESS;
 }
        return EXIT_SUCCESS;
 }
Impressum, Datenschutz