]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/agilent-dmm/sched.c
Fix similar broken error handling on several serial calls.
[libsigrok.git] / src / hardware / agilent-dmm / sched.c
index 7b41036542220211acf84586da305e2a50d701bf..b555cd8b93b4c5a1761f96d518fdf9b8a2454f3a 100644 (file)
@@ -106,7 +106,7 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
        if (revents == G_IO_IN) {
                /* Serial data arrived. */
                while(AGDMM_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;
                        devc->buflen += len;
@@ -137,11 +137,11 @@ static int agdmm_send(const struct sr_dev_inst *sdi, const char *cmd)
        sr_spew("Sending '%s'.", cmd);
        strncpy(buf, cmd, 28);
        if (!strncmp(buf, "*IDN?", 5))
-               strncat(buf, "\r\n", 32);
+               strcat(buf, "\r\n");
        else
-               strncat(buf, "\n\r\n", 32);
-       if (serial_write(serial, buf, strlen(buf)) == -1) {
-               sr_err("Failed to send: %s.", strerror(errno));
+               strcat(buf, "\n\r\n");
+       if (serial_write_blocking(serial, buf, strlen(buf)) < strlen(buf)) {
+               sr_err("Failed to send.");
                return SR_ERR;
        }