From 612db3c44b5ab493d8fce9457c5807b15d169ea6 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Sun, 21 Sep 2014 18:44:20 +0100 Subject: [PATCH] gmc-mh-1x-2x: Make serial write calls block. 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c index 3942ede6..d0cd1940 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.c +++ b/src/hardware/gmc-mh-1x-2x/protocol.c @@ -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; }