]> sigrok.org Git - libsigrok.git/commitdiff
gmc-mh-1x-2x: Make serial write call block, and fix error handling.
authorMartin Ling <redacted>
Sun, 21 Sep 2014 17:40:47 +0000 (18:40 +0100)
committerUwe Hermann <redacted>
Wed, 24 Sep 2014 21:30:30 +0000 (23:30 +0200)
This call was previously nonblocking, but there is no handling of partial
writes. It is called from config_set where it is free to block.

Also fix error handling: serial_write can return any negative error code,
not just -1.

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

index e6de8d52d7229c691ab8d46051afb26388ee19b7..3942ede6cae3d9ba054acae78c65ccb9ef52c297 100644 (file)
@@ -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. */