]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/fluke-dmm/fluke.c
Introduce standard implementation of the dev_list() callback
[libsigrok.git] / src / hardware / fluke-dmm / fluke.c
index 159a4f9f291d1761e72c72cccbc2375c9f759103..3629b5f373e1cbbf8e6cd2908efbaaa5569b7708 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
 #include <glib.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 #include "fluke-dmm.h"
 
-static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi,
+static struct sr_datafeed_analog_old *handle_qm_18x(const struct sr_dev_inst *sdi,
                char **tokens)
 {
-       struct sr_datafeed_analog *analog;
+       struct sr_datafeed_analog_old *analog;
        float fvalue;
        char *e, *u;
        gboolean is_oor;
@@ -58,7 +59,7 @@ static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi,
        while (*e && *e == ' ')
                e++;
 
-       analog = g_malloc0(sizeof(struct sr_datafeed_analog));
+       analog = g_malloc0(sizeof(struct sr_datafeed_analog_old));
        analog->data = g_malloc(sizeof(float));
        analog->channels = sdi->channels;
        analog->num_samples = 1;
@@ -153,10 +154,10 @@ static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi,
        return analog;
 }
 
-static struct sr_datafeed_analog *handle_qm_28x(const struct sr_dev_inst *sdi,
+static struct sr_datafeed_analog_old *handle_qm_28x(const struct sr_dev_inst *sdi,
                char **tokens)
 {
-       struct sr_datafeed_analog *analog;
+       struct sr_datafeed_analog_old *analog;
        float fvalue;
 
        if (!tokens[1])
@@ -167,7 +168,7 @@ static struct sr_datafeed_analog *handle_qm_28x(const struct sr_dev_inst *sdi,
                return NULL;
        }
 
-       analog = g_malloc0(sizeof(struct sr_datafeed_analog));
+       analog = g_malloc0(sizeof(struct sr_datafeed_analog_old));
        analog->data = g_malloc(sizeof(float));
        analog->channels = sdi->channels;
        analog->num_samples = 1;
@@ -361,7 +362,7 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens)
 {
        struct dev_context *devc;
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_analog analog;
+       struct sr_datafeed_analog_old analog;
        float fvalue;
 
        if (!strcmp(tokens[0], "9.9E+37")) {
@@ -396,9 +397,9 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens)
        analog.mq = devc->mq;
        analog.unit = devc->unit;
        analog.mqflags = 0;
-       packet.type = SR_DF_ANALOG;
+       packet.type = SR_DF_ANALOG_OLD;
        packet.payload = &analog;
-       sr_session_send(devc->cb_data, &packet);
+       sr_session_send(sdi, &packet);
        devc->num_samples++;
 
 }
@@ -408,7 +409,7 @@ static void handle_line(const struct sr_dev_inst *sdi)
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_analog *analog;
+       struct sr_datafeed_analog_old *analog;
        int num_tokens, n, i;
        char cmd[16], **tokens;
 
@@ -432,7 +433,7 @@ static void handle_line(const struct sr_dev_inst *sdi)
                if (devc->profile->model == FLUKE_187 || devc->profile->model == FLUKE_189) {
                        devc->expect_response = FALSE;
                        analog = handle_qm_18x(sdi, tokens);
-               } else if (devc->profile->model == FLUKE_287) {
+               } else if (devc->profile->model == FLUKE_287 || devc->profile->model == FLUKE_289) {
                        devc->expect_response = FALSE;
                        analog = handle_qm_28x(sdi, tokens);
                } else if (devc->profile->model == FLUKE_190) {
@@ -464,9 +465,9 @@ static void handle_line(const struct sr_dev_inst *sdi)
 
        if (analog) {
                /* Got a measurement. */
-               packet.type = SR_DF_ANALOG;
+               packet.type = SR_DF_ANALOG_OLD;
                packet.payload = analog;
-               sr_session_send(devc->cb_data, &packet);
+               sr_session_send(sdi, &packet);
                devc->num_samples++;
                g_free(analog->data);
                g_free(analog);
@@ -508,7 +509,7 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
-               sdi->driver->dev_acquisition_stop(sdi, cb_data);
+               sdi->driver->dev_acquisition_stop(sdi);
                return TRUE;
        }