X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/hmcfgusb/blobdiff_plain/885a84e3a91964fb6dada1120be301102268e6ab..fbbbfa37bd5adae5eabd94e6db96be584998ffd6:/hmsniff.c?ds=inline diff --git a/hmsniff.c b/hmsniff.c index 67a2df6..837f4e0 100644 --- a/hmsniff.c +++ b/hmsniff.c @@ -138,12 +138,12 @@ struct recv_data { int wrong_hmid; }; -static void parse_hmcfgusb(uint8_t *buf, int buf_len, void *data) +static int parse_hmcfgusb(uint8_t *buf, int buf_len, void *data) { struct recv_data *rdata = data; if (buf_len < 1) - return; + return 1; switch(buf[0]) { case 'E': @@ -164,6 +164,8 @@ static void parse_hmcfgusb(uint8_t *buf, int buf_len, void *data) hexdump(buf, buf_len, "Unknown> "); break; } + + return 1; } int main(int argc, char **argv) @@ -186,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) { @@ -197,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; @@ -205,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); } } }