]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/agilent-dmm/sched.c
agilent-dmm: Convert to SR_DF_ANALOG.
[libsigrok.git] / src / hardware / agilent-dmm / sched.c
index d1b765665c2bb9dbfedfed684ff3627f118d2660..0dd1c71d9d7a7607e704ad6ef15b0a75294e50f9 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
 #include <math.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 #include "agilent-dmm.h"
 
@@ -121,8 +121,8 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
 
        dispatch(sdi);
 
-       if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
-               sdi->driver->dev_acquisition_stop(sdi, cb_data);
+       if (sr_sw_limits_check(&devc->limits))
+               sdi->driver->dev_acquisition_stop(sdi);
 
        return TRUE;
 }
@@ -265,6 +265,9 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
        struct dev_context *devc;
        struct sr_datafeed_packet packet;
        struct sr_datafeed_analog analog;
+       struct sr_analog_encoding encoding;
+       struct sr_analog_meaning meaning;
+       struct sr_analog_spec spec;
        float fvalue;
        const char *s;
        char *mstr;
@@ -296,18 +299,18 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
                        fvalue /= devc->cur_divider;
        }
 
-       memset(&analog, 0, sizeof(struct sr_datafeed_analog));
-       analog.mq = devc->cur_mq;
-       analog.unit = devc->cur_unit;
-       analog.mqflags = devc->cur_mqflags;
-       analog.channels = sdi->channels;
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+       analog.meaning->mq = devc->cur_mq;
+       analog.meaning->unit = devc->cur_unit;
+       analog.meaning->mqflags = devc->cur_mqflags;
+       analog.meaning->channels = sdi->channels;
        analog.num_samples = 1;
        analog.data = &fvalue;
        packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
-       sr_session_send(devc->cb_data, &packet);
+       sr_session_send(sdi, &packet);
 
-       devc->num_samples++;
+       sr_sw_limits_update_samples_read(&devc->limits, 1);
 
        return SR_OK;
 }
@@ -515,7 +518,7 @@ SR_PRIV const struct agdmm_job agdmm_jobs_u12xx[] = {
        { 143, send_stat },
        { 1000, send_conf },
        { 143, send_fetc },
-       { 0, NULL }
+       ALL_ZERO
 };
 
 SR_PRIV const struct agdmm_recv agdmm_recvs_u123x[] = {
@@ -525,7 +528,7 @@ SR_PRIV const struct agdmm_recv agdmm_recvs_u123x[] = {
        { "^\"(V|MV|A|UA|FREQ),(\\d),(AC|DC)\"$", recv_conf_u123x },
        { "^\"(RES|CAP),(\\d)\"$", recv_conf_u123x},
        { "^\"(DIOD)\"$", recv_conf },
-       { NULL, NULL }
+       ALL_ZERO
 };
 
 SR_PRIV const struct agdmm_recv agdmm_recvs_u124x[] = {
@@ -537,7 +540,7 @@ SR_PRIV const struct agdmm_recv agdmm_recvs_u124x[] = {
        { "^\"(CPER:[40]-20mA) ([-+][0-9\\.E\\-+]+),([-+][0-9\\.E\\-+]+)\"$", recv_conf_u124x_5x },
        { "^\"(T[0-9]:[A-Z]+) ([A-Z]+)\"$", recv_conf_u124x_5x },
        { "^\"(DIOD)\"$", recv_conf },
-       { NULL, NULL }
+       ALL_ZERO
 };
 
 SR_PRIV const struct agdmm_recv agdmm_recvs_u125x[] = {
@@ -549,5 +552,5 @@ SR_PRIV const struct agdmm_recv agdmm_recvs_u125x[] = {
        { "^\"(CPER:[40]-20mA) ([-+][0-9\\.E\\-+]+),([-+][0-9\\.E\\-+]+)\"$", recv_conf_u124x_5x },
        { "^\"(T[0-9]:[A-Z]+) ([A-Z]+)\"$", recv_conf_u124x_5x },
        { "^\"(DIOD)\"$", recv_conf },
-       { NULL, NULL }
+       ALL_ZERO
 };