From: Martin Ling Date: Sun, 21 Sep 2014 17:40:47 +0000 (+0100) Subject: gmc-mh-1x-2x: Make serial write call block, and fix error handling. X-Git-Tag: libsigrok-0.4.0~957 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e1960467ce43cd4e327579c3a0537b611d43f31e;p=libsigrok.git gmc-mh-1x-2x: Make serial write call block, and fix error handling. 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. --- diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c index e6de8d52..3942ede6 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.c +++ b/src/hardware/gmc-mh-1x-2x/protocol.c @@ -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. */