]> git.zerfleddert.de Git - hmcfgusb/commitdiff
increase timeout granularity to handle missing acks on culfw-devices
authorMichael Gernoth <michael@gernoth.net>
Thu, 6 Mar 2014 21:37:49 +0000 (22:37 +0100)
committerMichael Gernoth <michael@gernoth.net>
Thu, 6 Mar 2014 21:37:49 +0000 (22:37 +0100)
culfw.c
flash-hmcfgusb.c
flash-ota.c
hmcfgusb.c
hmland.c
hmsniff.c

diff --git a/culfw.c b/culfw.c
index a4c949baff77fdc6e1325c9a236bec427836f7c8..6cfa975736318aeaa7049136555b0148a340aef9 100644 (file)
--- a/culfw.c
+++ b/culfw.c
@@ -141,7 +141,7 @@ int culfw_poll(struct culfw_dev *dev, int timeout)
        pfds[0].fd = dev->fd;
        pfds[0].events = POLLIN;
 
-       ret = poll(pfds, 1, timeout * 1000);
+       ret = poll(pfds, 1, timeout);
        if (ret == -1)
                return -1;
 
index 45d467f08451aa63d76df62fec8dc3136f9eaabb..0f0b9cef707b2b48424942d28b6144bc381d39f1 100644 (file)
@@ -134,7 +134,7 @@ int main(int argc, char **argv)
                        printf("Waiting for ack...\n");
                do {
                        errno = 0;
-                       pfd = hmcfgusb_poll(dev, 1);
+                       pfd = hmcfgusb_poll(dev, 1000);
                        if ((pfd < 0) && errno) {
                                if (errno != ETIMEDOUT) {
                                        perror("\n\nhmcfgusb_poll");
index 31e2ab5eced06184ef446b7b266679c3253525be..634e19b2b0db0c09af00ffb81d39114d6ad9d94c 100644 (file)
@@ -228,7 +228,7 @@ int send_hm_message(struct ota_dev *dev, struct recv_data *rdata, uint8_t *msg)
                                        }
                                }
                                errno = 0;
-                               pfd = hmcfgusb_poll(dev->hmcfgusb, 1);
+                               pfd = hmcfgusb_poll(dev->hmcfgusb, 1000);
                                if ((pfd < 0) && errno) {
                                        if (errno != ETIMEDOUT) {
                                                perror("\n\nhmcfgusb_poll");
@@ -263,7 +263,7 @@ int send_hm_message(struct ota_dev *dev, struct recv_data *rdata, uint8_t *msg)
                                        int pfd;
                                        do {
                                                errno = 0;
-                                               pfd = culfw_poll(dev->culfw, 1);
+                                               pfd = culfw_poll(dev->culfw, 200);
                                                if ((pfd < 0) && errno) {
                                                        if (errno != ETIMEDOUT) {
                                                                perror("\n\nculfw_poll");
@@ -305,7 +305,7 @@ static int switch_speed(struct ota_dev *dev, struct recv_data *rdata, uint8_t sp
 
                        while (1) {
                                errno = 0;
-                               pfd = hmcfgusb_poll(dev->hmcfgusb, 1);
+                               pfd = hmcfgusb_poll(dev->hmcfgusb, 1000);
                                if ((pfd < 0) && errno) {
                                        if (errno != ETIMEDOUT) {
                                                perror("\n\nhmcfgusb_poll");
@@ -420,7 +420,7 @@ int main(int argc, char **argv)
                        culfw_send(dev.culfw, "V\r\n", 3);
 
                        errno = 0;
-                       pfd = culfw_poll(dev.culfw, 1);
+                       pfd = culfw_poll(dev.culfw, 1000);
                        if ((pfd < 0) && errno) {
                                if (errno != ETIMEDOUT) {
                                        perror("\n\nhmcfgusb_poll");
@@ -486,7 +486,7 @@ int main(int argc, char **argv)
 
                while (1) {
                        errno = 0;
-                       pfd = hmcfgusb_poll(dev.hmcfgusb, 1);
+                       pfd = hmcfgusb_poll(dev.hmcfgusb, 1000);
                        if ((pfd < 0) && errno) {
                                if (errno != ETIMEDOUT) {
                                        perror("\n\nhmcfgusb_poll");
@@ -516,11 +516,11 @@ int main(int argc, char **argv)
                errno = 0;
                switch (dev.type) {
                        case DEVICE_TYPE_CULFW:
-                               pfd = culfw_poll(dev.culfw, 1);
+                               pfd = culfw_poll(dev.culfw, 1000);
                                break;
                        case DEVICE_TYPE_HMCFGUSB:
                        default:
-                               pfd = hmcfgusb_poll(dev.hmcfgusb, 1);
+                               pfd = hmcfgusb_poll(dev.hmcfgusb, 1000);
                                break;
                }
 
@@ -713,11 +713,11 @@ int main(int argc, char **argv)
                errno = 0;
                switch(dev.type) {
                        case DEVICE_TYPE_CULFW:
-                               pfd = culfw_poll(dev.culfw, 1);
+                               pfd = culfw_poll(dev.culfw, 1000);
                                break;
                        case DEVICE_TYPE_HMCFGUSB:
                        default:
-                               pfd = hmcfgusb_poll(dev.hmcfgusb, 1);
+                               pfd = hmcfgusb_poll(dev.hmcfgusb, 1000);
                                break;
                }
                if ((pfd < 0) && errno) {
index c90410a4d0ad2411dcc228ac9c2f291e6e44af0e..0e118661fa7007397f19c52b647f96299c9c1e22 100644 (file)
@@ -433,13 +433,11 @@ int hmcfgusb_poll(struct hmcfgusb_dev *dev, int timeout)
                return -1;
        } else if (err == 0) {
                /* No pending timeout or a sane platform */
-               tv.tv_sec = timeout;
        } else {
                if ((tv.tv_sec == 0) && (tv.tv_usec == 0)) {
                        usb_event = 1;
-               } else if (tv.tv_sec > timeout) {
-                       tv.tv_sec = timeout;
-                       tv.tv_usec = 0;
+               } else if ((tv.tv_sec * 1000) < timeout) {
+                       timeout = tv.tv_sec * 1000;
                }
        }
 
@@ -448,7 +446,7 @@ int hmcfgusb_poll(struct hmcfgusb_dev *dev, int timeout)
                        dev->pfd[i].revents = 0;
                }
 
-               n = poll(dev->pfd, dev->n_pfd, tv.tv_sec * 1000);
+               n = poll(dev->pfd, dev->n_pfd, timeout);
                if (n < 0) {
                        perror("poll");
                        errno = 0;
index fd2d09e4881c60c4f739e68282c028ebb06272b1..38cd7a3a9607442316181181b4f3f0304ce3c439 100644 (file)
--- a/hmland.c
+++ b/hmland.c
@@ -508,7 +508,7 @@ static int comm(int fd_in, int fd_out, int master_socket, int flags)
        while(!quit) {
                int fd;
 
-               fd = hmcfgusb_poll(dev, 1);     /* Wakeup device/bus at least once a second */
+               fd = hmcfgusb_poll(dev, 1000);  /* Wakeup device/bus at least once a second */
                if (fd >= 0) {
                        if (fd == master_socket) {
                                int client;
index 39133d3111cae2b235fedb80b86319a6fe089f08..a3cbe7a244ffd96304018b7e5a383a68bee62f13 100644 (file)
--- a/hmsniff.c
+++ b/hmsniff.c
@@ -201,7 +201,7 @@ int main(int argc, char **argv)
                                rdata.wrong_hmid = 0;
                                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
                        }
-                       fd = hmcfgusb_poll(dev, 1);
+                       fd = hmcfgusb_poll(dev, 1000);
                        if (fd >= 0) {
                                fprintf(stderr, "activity on unknown fd %d!\n", fd);
                                continue;
Impressum, Datenschutz