]> sigrok.org Git - libsigrok.git/commitdiff
gmc-mh-1x-2x: Make serial write calls block.
authorMartin Ling <redacted>
Sun, 21 Sep 2014 17:44:20 +0000 (18:44 +0100)
committerUwe Hermann <redacted>
Wed, 24 Sep 2014 21:30:30 +0000 (23:30 +0200)
These calls are executed from an event handler and were previously nonblocking,
but have no partial write handling. They send short packets so should be OK to
block, most likely the output buffer will be empty anyway.

Fix error handling for some: serial_write can return any negative error code.

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

index 3942ede6cae3d9ba054acae78c65ccb9ef52c297..d0cd194089286b447833c698cb0460ce696dc273 100644 (file)
@@ -1307,7 +1307,7 @@ 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(serial, msg, sizeof(msg)) == -1) {
+       if (serial_write_blocking(serial, msg, sizeof(msg)) < 0) {
                return SR_ERR;
        }
 
@@ -1336,13 +1336,13 @@ 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(serial, msg, sizeof(msg)) < 0)
+               if (serial_write_blocking(serial, msg, sizeof(msg)) < 0)
                        return SR_ERR;
                g_usleep(1*1000*1000);
-               if (serial_write(serial, msg, sizeof(msg)) < 0)
+               if (serial_write_blocking(serial, msg, sizeof(msg)) < 0)
                        return SR_ERR;
                g_usleep(1*1000*1000);
-               if (serial_write(serial, msg, sizeof(msg)) < 0)
+               if (serial_write_blocking(serial, msg, sizeof(msg)) < 0)
                        return SR_ERR;
                g_usleep(1*1000*1000);
                serial_flush(serial);
@@ -1350,7 +1350,7 @@ 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(serial, msg, sizeof(msg)) == -1) {
+       if (serial_write_blocking(serial, msg, sizeof(msg)) < 0) {
                return SR_ERR;
        }