]> sigrok.org Git - libsigrok.git/commitdiff
gmc-mh-1x-2x: Fix blocking serial write timeout.
authorUwe Hermann <redacted>
Sun, 13 Sep 2015 21:57:32 +0000 (23:57 +0200)
committerUwe Hermann <redacted>
Sun, 13 Sep 2015 22:10:24 +0000 (00:10 +0200)
This fixes bug #432.

src/hardware/gmc-mh-1x-2x/protocol.c

index f544c2719cb647c048cd3faddb5c49844bcb3c00..879007da76bd3c9902a835078357a81d1e34cbdf 100644 (file)
@@ -1312,7 +1312,8 @@ int req_meas14(const struct sr_dev_inst *sdi)
        devc->cmd_idx = 0;
        create_cmd_14(devc->addr, 8, params, msg);
        devc->req_sent_at = g_get_monotonic_time();
-       if (serial_write_blocking(serial, msg, sizeof(msg), 0) < (int)sizeof(msg)) {
+       if (serial_write_blocking(serial, msg, sizeof(msg),
+                       serial_timeout(serial, sizeof(msg))) < (int)sizeof(msg)) {
                return SR_ERR;
        }
 
@@ -1341,13 +1342,16 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
 
        if (power_on) {
                sr_info("Write some data and wait 3s to turn on powered off device...");
-               if (serial_write_blocking(serial, msg, sizeof(msg), 0) < 0)
+               if (serial_write_blocking(serial, msg, sizeof(msg),
+                               serial_timeout(serial, sizeof(msg))) < 0)
                        return SR_ERR;
                g_usleep(1 * 1000 * 1000);
-               if (serial_write_blocking(serial, msg, sizeof(msg), 0) < 0)
+               if (serial_write_blocking(serial, msg, sizeof(msg),
+                               serial_timeout(serial, sizeof(msg))) < 0)
                        return SR_ERR;
                g_usleep(1 * 1000 * 1000);
-               if (serial_write_blocking(serial, msg, sizeof(msg), 0) < 0)
+               if (serial_write_blocking(serial, msg, sizeof(msg),
+                               serial_timeout(serial, sizeof(msg))) < 0)
                        return SR_ERR;
                g_usleep(1 * 1000 * 1000);
                serial_flush(serial);
@@ -1355,7 +1359,8 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
 
        /* Write message and wait for reply */
        devc->req_sent_at = g_get_monotonic_time();
-       if (serial_write_blocking(serial, msg, sizeof(msg), 0) < (int)sizeof(msg)) {
+       if (serial_write_blocking(serial, msg, sizeof(msg),
+                       serial_timeout(serial, sizeof(msg))) < (int)sizeof(msg)) {
                return SR_ERR;
        }
 
@@ -1532,7 +1537,8 @@ SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *s
                params[0] = 5;
                params[1] = 5;
                create_cmd_14(devc->addr, 6, params, msg);
-               if (serial_write_blocking(sdi->conn, msg, sizeof(msg), 0) < 0)
+               if (serial_write_blocking(sdi->conn, msg, sizeof(msg),
+                               serial_timeout(sdi->conn, sizeof(msg))) < 0)
                        return SR_ERR;
                else
                        g_usleep(2 * 1000 * 1000); /* Wait to ensure transfer before interface switched off. */