]> sigrok.org Git - libsigrok.git/blobdiff - hardware/agilent-dmm/sched.c
Fix limit_samples check in various drivers.
[libsigrok.git] / hardware / agilent-dmm / sched.c
index 5ae73aca1824796871cd92999bf15b530113fc9d..67c2a1b66330d01f29a7edc2c927ff192065216e 100644 (file)
@@ -93,6 +93,8 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
        struct dev_context *devc;
        int len;
 
+       (void)fd;
+
        if (!(sdi = cb_data))
                return TRUE;
 
@@ -102,7 +104,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(fd, devc->buf + devc->buflen, 1);
+                       len = serial_read(devc->serial, devc->buf + devc->buflen, 1);
                        if (len < 1)
                                break;
                        devc->buflen += len;
@@ -117,7 +119,7 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
 
        dispatch(sdi);
 
-       if (devc->num_samples >= devc->limit_samples)
+       if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
                sdi->driver->dev_acquisition_stop(sdi, cb_data);
 
        return TRUE;
@@ -135,7 +137,7 @@ static int agdmm_send(const struct sr_dev_inst *sdi, const char *cmd)
                strncat(buf, "\r\n", 32);
        else
                strncat(buf, "\n\r\n", 32);
-       if (serial_write(devc->serial->fd, buf, strlen(buf)) == -1) {
+       if (serial_write(devc->serial, buf, strlen(buf)) == -1) {
                sr_err("Failed to send: %s.", strerror(errno));
                return SR_ERR;
        }
@@ -241,7 +243,7 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
                return SR_OK;
 
        if (!strcmp(g_match_info_get_string(match), "+9.90000000E+37")) {
-               /* An invalid measurement shows up on the display as "O.L, but
+               /* An invalid measurement shows up on the display as "O.L", but
                 * comes through like this. Since comparing 38-digit floats
                 * is rather problematic, we'll cut through this here. */
                fvalue = NAN;