]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/gmc-mh-1x-2x/protocol.c
gmc-mh-1x-2x: Make serial write call block, and fix error handling.
[libsigrok.git] / src / hardware / gmc-mh-1x-2x / protocol.c
index 06cae38b07d18f59f5de3e52fb1b192d637ac77d..3942ede6cae3d9ba054acae78c65ccb9ef52c297 100644 (file)
@@ -1107,7 +1107,7 @@ SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data)
 
        if (revents == G_IO_IN) { /* Serial data arrived. */
                while (GMC_BUFSIZE - devc->buflen - 1 > 0) {
-                       len = serial_read(serial, devc->buf + devc->buflen, 1);
+                       len = serial_read_nonblocking(serial, devc->buf + devc->buflen, 1);
                        if (len < 1)
                                break;
                        buf = *(devc->buf + devc->buflen);
@@ -1201,7 +1201,7 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data)
 
        if (revents == G_IO_IN) { /* Serial data arrived. */
                while (GMC_BUFSIZE - devc->buflen - 1 > 0) {
-                       len = serial_read(serial, devc->buf + devc->buflen, 1);
+                       len = serial_read_nonblocking(serial, devc->buf + devc->buflen, 1);
                        if (len < 1)
                                break;
                        buf = *(devc->buf + devc->buflen);
@@ -1529,7 +1529,7 @@ 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(sdi->conn, msg, sizeof(msg)) == -1)
+               if (serial_write_blocking(sdi->conn, msg, sizeof(msg)) < 0)
                        return SR_ERR;
                else
                        g_usleep(2000000); /* Wait to ensure transfer before interface switched off. */