projects
/
hmcfgusb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add possibility to log network communication
[hmcfgusb]
/
hmsniff.c
diff --git
a/hmsniff.c
b/hmsniff.c
index 67a2df6ae004e4fdd6b318c1154c87ed1ea75012..a3cbe7a244ffd96304018b7e5a383a68bee62f13 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"
@@
-138,12
+139,12
@@
struct recv_data {
int wrong_hmid;
};
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)
{
struct recv_data *rdata = data;
if (buf_len < 1)
- return;
+ return
1
;
switch(buf[0]) {
case 'E':
switch(buf[0]) {
case 'E':
@@
-164,6
+165,8
@@
static void parse_hmcfgusb(uint8_t *buf, int buf_len, void *data)
hexdump(buf, buf_len, "Unknown> ");
break;
}
hexdump(buf, buf_len, "Unknown> ");
break;
}
+
+ return 1;
}
int main(int argc, char **argv)
}
int main(int argc, char **argv)
@@
-186,6
+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, 1);
hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
while(!quit) {
hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
while(!quit) {
@@
-197,14
+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, 10);
+ fd = hmcfgusb_poll(dev, 10
00
);
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;
+ if (errno != ETIMEDOUT) {
+ perror("hmcfgusb_poll");
+ break;
+ } else {
+ /* periodically wakeup the device */
+ hmcfgusb_send_null_frame(dev, 1);
+ }
}
}
}
}
}
}
Impressum
,
Datenschutz