]> sigrok.org Git - libsigrok.git/commitdiff
several DMMs: set DC flag for diode mode
authorGerhard Sittig <redacted>
Sun, 4 Feb 2018 21:26:23 +0000 (22:26 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 21:40:58 +0000 (22:40 +0100)
Few DMM drivers already did it. This commit adjusts the remaining DMM
drivers, to set the "DC" flag for measurements in diode mode.

This fixes bug #144.

Although I don't have the hardware to test, the nature of the change and
the arrangement of driver code suggests it's good. When a meter already
communicated the "DC" status, the change does nothing and won't harm.
The change ensures "DC" is flagged for those meters which previously
didn't, which is desirable.

15 files changed:
src/dmm/asycii.c
src/dmm/bm25x.c
src/dmm/dtm0660.c
src/dmm/es519xx.c
src/dmm/fs9721.c
src/dmm/fs9922.c
src/dmm/metex14.c
src/dmm/ut71x.c
src/dmm/vc870.c
src/hardware/agilent-dmm/protocol.c
src/hardware/brymen-bm86x/protocol.c
src/hardware/brymen-dmm/parser.c
src/hardware/fluke-dmm/protocol.c
src/hardware/gmc-mh-1x-2x/protocol.c
src/hardware/victor-dmm/protocol.c

index 54858ffa60b91737191eeb3c90834b0393eb9d34..1bb80861e6d989da91ad48f71b730dcaef55330d 100644 (file)
@@ -379,7 +379,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
        if (info->is_dc)
                analog->meaning->mqflags |= SR_MQFLAG_DC;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        if (info->is_peak_max)
                analog->meaning->mqflags |= SR_MQFLAG_MAX;
        if (info->is_peak_min)
index 385d246e6e53e85bdcf410256b4ffb540c170a89..b838d1ce73b5dda3744118ef69858e974e7229f8 100644 (file)
@@ -173,7 +173,7 @@ SR_PRIV int sr_brymen_bm25x_parse(const uint8_t *buf, float *floatval,
                analog->meaning->mq = SR_MQ_VOLTAGE;
                analog->meaning->unit = SR_UNIT_VOLT;
                if ((analog->meaning->mqflags & (SR_MQFLAG_DC | SR_MQFLAG_AC)) == 0)
-                       analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+                       analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        }
        if (buf[14] & 2) {
                analog->meaning->mq = SR_MQ_CURRENT;
index e10e773eadd37918e3ee8692739cb304a3c2469d..b23c04abdd98a65ac79e6fe4dc62635211f34d06 100644 (file)
@@ -318,7 +318,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
        if (info->is_auto)
                analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        if (info->is_hold)
                analog->meaning->mqflags |= SR_MQFLAG_HOLD;
        if (info->is_rel)
index 4ebc293d8191939c4bf242e83a1354e94ac9dc49..202b64859a9986105e2674e0367e9f273ac02592 100644 (file)
@@ -502,7 +502,7 @@ static void handle_flags(struct sr_datafeed_analog *analog,
        if (info->is_auto)
                analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        if (info->is_hold)
                /*
                * Note: HOLD only affects the number displayed on the LCD,
index 17c75178e2184de876708ba3f5ec0a27022ffe37..c13bdbcf675a28bb5d1914c3f6ab44fc7102d716 100644 (file)
@@ -302,7 +302,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
        if (info->is_auto)
                analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        if (info->is_hold)
                analog->meaning->mqflags |= SR_MQFLAG_HOLD;
        if (info->is_rel)
index b98d8ee29e6d14bb6624d218d3497f35dbd2859c..292da6b5de5592335ce39f1a7310e90f01cd7512 100644 (file)
@@ -290,7 +290,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
        if (info->is_auto)
                analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        if (info->is_hold)
                analog->meaning->mqflags |= SR_MQFLAG_HOLD;
        if (info->is_max)
@@ -385,6 +385,6 @@ SR_PRIV void sr_fs9922_z1_diode(struct sr_datafeed_analog *analog, void *info)
        if (info_local->is_z1) {
                analog->meaning->mq = SR_MQ_VOLTAGE;
                analog->meaning->unit = SR_UNIT_VOLT;
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        }
 }
index 0dd5d2edc8602dada2c4c24666bf818f239d46c2..687df9063fbb50cf14679dae361d53030763b4e5 100644 (file)
@@ -243,7 +243,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
        if (info->is_dc)
                analog->meaning->mqflags |= SR_MQFLAG_DC;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
 }
 
 static gboolean flags_valid(const struct metex14_info *info)
index 9a7d2eab93b0776bd56e1a75fcaf9fea86887cb1..6dbf23a47e1cbb5ca5f4881d24d4cc1c8fd9ba92 100644 (file)
@@ -284,7 +284,7 @@ static void handle_flags(struct sr_datafeed_analog *analog,
        if (info->is_auto)
                analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
 }
 
 static gboolean flags_valid(const struct ut71x_info *info)
index b0095b418dbcd162014074dfcbcf991c8bae76ef..2af7cc99c6c6d6008935ce1c5827dbce8fbedb13 100644 (file)
@@ -360,7 +360,7 @@ static void handle_flags(struct sr_datafeed_analog *analog,
        if (info->is_auto)
                analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        if (info->is_hold)
                /*
                 * Note: HOLD only affects the number displayed on the LCD,
index 23768a6a28c6f77c7e61f7f4cb2b1da151102689..764136e8f437734b9537b5001265060ef6cd6b9e 100644 (file)
@@ -600,7 +600,7 @@ static int recv_conf_u123x(const struct sr_dev_inst *sdi, GMatchInfo *match)
        } else if (!strcmp(mstr, "DIOD")) {
                devc->cur_mq[i] = SR_MQ_VOLTAGE;
                devc->cur_unit[i] = SR_UNIT_VOLT;
-               devc->cur_mqflags[i] = SR_MQFLAG_DIODE;
+               devc->cur_mqflags[i] = SR_MQFLAG_DIODE | SR_MQFLAG_DC;
                devc->cur_exponent[i] = 0;
                devc->cur_digits[i] = 3;
        } else if (!strcmp(mstr, "CAP")) {
@@ -738,7 +738,7 @@ static int recv_conf_u124x_5x(const struct sr_dev_inst *sdi, GMatchInfo *match)
        } else if (!strcmp(mstr, "DIOD")) {
                devc->cur_mq[i] = SR_MQ_VOLTAGE;
                devc->cur_unit[i] = SR_UNIT_VOLT;
-               devc->cur_mqflags[i] = SR_MQFLAG_DIODE;
+               devc->cur_mqflags[i] = SR_MQFLAG_DIODE | SR_MQFLAG_DC;
                devc->cur_exponent[i] = 0;
                if (devc->profile->model == KEYSIGHT_U1281 ||
                    devc->profile->model == KEYSIGHT_U1282) {
@@ -871,7 +871,7 @@ static int recv_log(const struct sr_dev_inst *sdi, GMatchInfo *match,
        if (mstr[12] & 1)  mqflags |= SR_MQFLAG_AVG;
        if (mstr[12] & 2)  mqflags |= SR_MQFLAG_MIN;
        if (mstr[12] & 4)  mqflags |= SR_MQFLAG_MAX;
-       if (function == 5) mqflags |= SR_MQFLAG_DIODE;
+       if (function == 5) mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        g_free(mstr);
 
        mq = mqs[function];
index 345fad57fcb49e0a2146006d0374a6b4d401c808..097b8874ef61c20b9a0c22b781eb3d515bd3c682 100644 (file)
@@ -99,8 +99,10 @@ static void brymen_bm86x_parse(unsigned char *buf, float *floatval,
                if (buf[8] & 0x01) {
                        analog[0].meaning->mq = SR_MQ_VOLTAGE;
                        analog[0].meaning->unit = SR_UNIT_VOLT;
-                       if (!strcmp(str, "diod"))
+                       if (!strcmp(str, "diod")) {
                                analog[0].meaning->mqflags |= SR_MQFLAG_DIODE;
+                               analog[0].meaning->mqflags |= SR_MQFLAG_DC;
+                       }
                } else if (buf[14] & 0x80) {
                        analog[0].meaning->mq = SR_MQ_CURRENT;
                        analog[0].meaning->unit = SR_UNIT_AMPERE;
index 2f55cdf70f2ea9d148e9dfe1f0ce526b8a86af01..d42ff45ac80549d8b8540168495283d201573b63 100644 (file)
@@ -276,7 +276,7 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
        }
 
        if (flags.is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        /* We can have both AC+DC in a single measurement. */
        if (flags.is_ac)
                analog->meaning->mqflags |= SR_MQFLAG_AC;
index af4fd56c62d129d6ecdf3bc5d83caf24219ef934..a5d8cefe888e61aaa5446624232a5dc79862b09e 100644 (file)
@@ -324,7 +324,7 @@ static void handle_qm_19x_meta(const struct sr_dev_inst *sdi, char **tokens)
                else if (meas_char == 3)
                        devc->mqflags |= SR_MQFLAG_DC | SR_MQFLAG_AC;
                else if (meas_char == 15)
-                       devc->mqflags |= SR_MQFLAG_DIODE;
+                       devc->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
                break;
        case 2:
                devc->mq = SR_MQ_CURRENT;
index 7d06b07176fbfb0d52423460adbb9c026e91d6f7..d1009b30eeca2a7eeecd5ef548e5911f21235884 100644 (file)
@@ -73,7 +73,7 @@ static void decode_ctmv_16(uint8_t ctmv, struct dev_context *devc)
        case 0x08: /* 1000 Diode */
                devc->mq = SR_MQ_VOLTAGE;
                devc->unit = SR_UNIT_VOLT;
-               devc->mqflags |= SR_MQFLAG_DIODE;
+               devc->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
                break;
        case 0x09: /* 1001 Ohm, °C */
        case 0x0a: /* 1010 kOhm */
@@ -197,7 +197,7 @@ static void decode_ctmv_18(uint8_t ctmv, struct dev_context *devc)
        case 0x05: /* 0101 Diode/Diode with buzzer */
                devc->mq = SR_MQ_VOLTAGE;
                devc->unit = SR_UNIT_VOLT;
-               devc->mqflags |= SR_MQFLAG_DIODE;
+               devc->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
                break;
        case 0x06: /* 0110 °C */
                devc->mq = SR_MQ_TEMPERATURE;
@@ -410,7 +410,7 @@ static void decode_ctmv_2x(uint8_t ctmv, struct dev_context *devc)
                devc->unit = SR_UNIT_VOLT;
                if (ctmv == 0x0f) {
                        devc->mq = SR_MQ_VOLTAGE;
-                       devc->mqflags |= SR_MQFLAG_DIODE;
+                       devc->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
                } else {
                        devc->mq = SR_MQ_CONTINUITY;
                        devc->scale += -5;
index 18b0cd1f73ecb33087b5701ce1febef9678c91d2..23dfe7ab4e711c02756144bfa36411fa07233a92 100644 (file)
@@ -185,7 +185,7 @@ static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
                if (is_diode) {
                        meaning.mq = SR_MQ_VOLTAGE;
                        meaning.unit = SR_UNIT_VOLT;
-                       meaning.mqflags |= SR_MQFLAG_DIODE;
+                       meaning.mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
                        if (ivalue < 0)
                                fvalue = NAN;
                } else {