]> sigrok.org Git - libsigrok.git/blobdiff - hardware/agilent-dmm/sched.c
GPL headers: Use correct project name.
[libsigrok.git] / hardware / agilent-dmm / sched.c
index 5ae73aca1824796871cd92999bf15b530113fc9d..da15e4d9a3a3dd4519a73eefaf19372938c65e38 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
  *
  * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
  *
@@ -91,18 +91,22 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
+       struct sr_serial_dev_inst *serial;
        int len;
 
+       (void)fd;
+
        if (!(sdi = cb_data))
                return TRUE;
 
        if (!(devc = sdi->priv))
                return TRUE;
 
+       serial = sdi->conn;
        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(serial, devc->buf + devc->buflen, 1);
                        if (len < 1)
                                break;
                        devc->buflen += len;
@@ -117,7 +121,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;
@@ -125,17 +129,18 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
 
 static int agdmm_send(const struct sr_dev_inst *sdi, const char *cmd)
 {
-       struct dev_context *devc;
+       struct sr_serial_dev_inst *serial;
        char buf[32];
 
-       devc = sdi->priv;
+       serial = sdi->conn;
+
        sr_spew("Sending '%s'.", cmd);
        strncpy(buf, cmd, 28);
        if (!strncmp(buf, "*IDN?", 5))
                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(serial, buf, strlen(buf)) == -1) {
                sr_err("Failed to send: %s.", strerror(errno));
                return SR_ERR;
        }
@@ -241,7 +246,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;
@@ -261,6 +266,7 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
        analog.mq = devc->cur_mq;
        analog.unit = devc->cur_unit;
        analog.mqflags = devc->cur_mqflags;
+       analog.probes = sdi->probes;
        analog.num_samples = 1;
        analog.data = &fvalue;
        packet.type = SR_DF_ANALOG;