- fd = hmcfgusb_poll(dev, 3600);
- if (fd >= 0) {
- fprintf(stderr, "activity on unknown fd %d!\n", fd);
- continue;
- } else if (fd == -1) {
- if (errno) {
- perror("hmcfgusb_poll");
- quit = 1;
+ while(!quit) {
+ int fd;
+
+ if (rdata.wrong_hmid) {
+ printf("changing hmId to 000000, this might reboot the device!\n");
+ hmcfgusb_send(dev, (unsigned char*)"A\00\00\00", 4, 1);
+ rdata.wrong_hmid = 0;
+ hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
+ }
+ fd = hmcfgusb_poll(dev, 1);
+ if (fd >= 0) {
+ fprintf(stderr, "activity on unknown fd %d!\n", fd);
+ continue;
+ } else if (fd == -1) {
+ if (errno) {
+ if (errno != ETIMEDOUT) {
+ perror("hmcfgusb_poll");
+ break;
+ } else {
+ /* periodically wakeup the device */
+ hmcfgusb_send_null_frame(dev, 1);
+ }
+ }