]> sigrok.org Git - libsigrok.git/commitdiff
fluke-dmm: Make serial write calls block, and fix error handling.
authorMartin Ling <redacted>
Sun, 21 Sep 2014 17:26:16 +0000 (18:26 +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.

Also fix error handling for these calls, which seems to have been retained from
previous direct usage of write() to a serial port fd.

src/hardware/fluke-dmm/fluke.c

index 242843dfc58f57316494fb2a663ed3bf21524d56..1110981b7c154be743120c3606ef2c6c39cc475e 100644 (file)
@@ -456,9 +456,8 @@ static void handle_line(const struct sr_dev_inst *sdi)
                                        /* Slip the request in now, before the main
                                         * timer loop asks for metadata again. */
                                        n = sprintf(cmd, "QM %d\r", devc->meas_type);
-                                       if (serial_write(serial, cmd, n) == -1)
-                                               sr_err("Unable to send QM (measurement): %s.",
-                                                               strerror(errno));
+                                       if (serial_write_blocking(serial, cmd, n) < 0)
+                                               sr_err("Unable to send QM (measurement).");
                                }
                        } else {
                                /* Response to QM <n> measurement request. */
@@ -526,8 +525,8 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data)
         * out-of-sync or temporary disconnect issues. */
        if ((devc->expect_response == FALSE && elapsed > devc->profile->poll_period)
                        || elapsed > devc->profile->timeout) {
-               if (serial_write(serial, "QM\r", 3) == -1)
-                       sr_err("Unable to send QM: %s.", strerror(errno));
+               if (serial_write_blocking(serial, "QM\r", 3) < 0)
+                       sr_err("Unable to send QM.");
                devc->cmd_sent_at = now;
                devc->expect_response = TRUE;
        }