]> git.zerfleddert.de Git - hmcfgusb/blobdiff - hmland.c
clarify inet_ntop error (it is fatal!)
[hmcfgusb] / hmland.c
index a9d9670186f8dc522b1bc772b3a1db689f0d3267..f3b7cf965df00e66f2c2cdfba805bb5f79462a12 100644 (file)
--- a/hmland.c
+++ b/hmland.c
@@ -455,7 +455,7 @@ static int comm(int fd_in, int fd_out, int master_socket, int flags)
        memset(out, 0, sizeof(out));
        out[0] = 'K';
        wait_for_h = 1;
-       hmcfgusb_send_null_frame(dev);
+       hmcfgusb_send_null_frame(dev, 1);
        hmcfgusb_send(dev, out, sizeof(out), 1);
 
        while(!quit) {
@@ -478,11 +478,18 @@ static int comm(int fd_in, int fd_out, int master_socket, int flags)
                        }
                } else if (fd == -1) {
                        if (errno) {
-                               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);
+                                       }
+                               }
                        }
                }
        }
@@ -603,7 +610,7 @@ static int socket_server(char *iface, int port, int flags)
                sin.sin_addr.s_addr = htonl(INADDR_ANY);
        } else {
                if (inet_pton(AF_INET, iface, &(sin.sin_addr.s_addr)) != 1) {
-                       perror("inet_ntop");
+                       fprintf(stderr, "Can't convert IP %s, aborting!\n", iface);
                        return EXIT_FAILURE;
                }
        }
Impressum, Datenschutz