]> sigrok.org Git - libsigrok.git/blobdiff - hardware/victor-dmm/protocol.c
Replace 'probe' with 'channel' in most places.
[libsigrok.git] / hardware / victor-dmm / protocol.c
index e2c05b02ffa5d7b2e3ade53bffcf4dc9e0c9e09b..6af51419326694c6241c349b850bb5c04a70a393 100644 (file)
@@ -40,16 +40,19 @@ static uint8_t decode_digit(uint8_t in)
        return out;
 }
 
-static void decode_buf(struct dev_context *devc, unsigned char *data)
+static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
 {
        struct sr_datafeed_packet packet;
        struct sr_datafeed_analog analog;
+       struct dev_context *devc;
        long factor, ivalue;
        uint8_t digits[4];
        gboolean is_duty, is_continuity, is_diode, is_ac, is_dc, is_auto;
        gboolean is_hold, is_max, is_min, is_relative, minus;
        float fvalue;
 
+       devc = sdi->priv;
+
        digits[0] = decode_digit(data[12]);
        digits[1] = decode_digit(data[11]);
        digits[2] = decode_digit(data[10]);
@@ -70,6 +73,7 @@ static void decode_buf(struct dev_context *devc, unsigned char *data)
        }
 
        /* Decimal point position */
+       factor = 0;
        switch (data[7] >> 4) {
        case 0x00:
                factor = 0;
@@ -134,7 +138,7 @@ static void decode_buf(struct dev_context *devc, unsigned char *data)
        }
 
        /* Scale flags on the right, continued */
-       is_max = is_min = TRUE;
+       is_max = is_min = FALSE;
        if (data[5] & 0x04)
                is_max = TRUE;
        if (data[5] & 0x08)
@@ -248,6 +252,7 @@ static void decode_buf(struct dev_context *devc, unsigned char *data)
        if (is_relative)
                analog.mqflags |= SR_MQFLAG_RELATIVE;
 
+       analog.channels = sdi->channels;
        analog.num_samples = 1;
        analog.data = &fvalue;
        packet.type = SR_DF_ANALOG;
@@ -259,7 +264,6 @@ static void decode_buf(struct dev_context *devc, unsigned char *data)
 
 SR_PRIV int victor_dmm_receive_data(struct sr_dev_inst *sdi, unsigned char *buf)
 {
-       struct dev_context *devc;
        GString *dbg;
        int i;
        unsigned char data[DMM_DATA_SIZE];
@@ -268,8 +272,6 @@ SR_PRIV int victor_dmm_receive_data(struct sr_dev_inst *sdi, unsigned char *buf)
                6, 13, 5, 11, 2, 7, 9, 8, 3, 10, 12, 0, 4, 1
        };
 
-       devc = sdi->priv;
-
        for (i = 0; i < DMM_DATA_SIZE && buf[i] == 0; i++);
        if (i == DMM_DATA_SIZE) {
                /* This DMM outputs all zeroes from time to time, just ignore it. */
@@ -290,7 +292,7 @@ SR_PRIV int victor_dmm_receive_data(struct sr_dev_inst *sdi, unsigned char *buf)
                g_string_free(dbg, TRUE);
        }
 
-       decode_buf(devc, data);
+       decode_buf(sdi, data);
 
        return SR_OK;
 }