- perror("hmcfgusb_poll");
- quit = 1;
- } else {
- /* periodically wakeup the device */
- hmcfgusb_send_null_frame(dev);
+ if (errno != ETIMEDOUT) {
+ perror("hmcfgusb_poll");
+ quit = 1;
+ } else {
+ /* periodically wakeup the device */
+ hmcfgusb_send_null_frame(dev, 1);
+ if (wait_for_h) {
+ memset(out, 0, sizeof(out));
+ out[0] = 'K';
+ hmcfgusb_send(dev, out, sizeof(out), 1);
+ }
+ }
+ }
+ }
+
+ if (reboot_seconds && ((dev->opened_at + reboot_seconds) <= time(NULL))) {
+ if (verbose) {
+ fprintf(stderr, "HM-CFG-USB running since %lu seconds, rebooting now...\n",
+ time(NULL) - dev->opened_at);