From: Gerhard Sittig Date: Sun, 4 Feb 2018 21:26:23 +0000 (+0100) Subject: several DMMs: set DC flag for diode mode X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=64aa214a22fdbc4a083f3cd6bd06755e6784b96c;p=libsigrok.git several DMMs: set DC flag for diode mode 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. --- diff --git a/src/dmm/asycii.c b/src/dmm/asycii.c index 54858ffa..1bb80861 100644 --- a/src/dmm/asycii.c +++ b/src/dmm/asycii.c @@ -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) diff --git a/src/dmm/bm25x.c b/src/dmm/bm25x.c index 385d246e..b838d1ce 100644 --- a/src/dmm/bm25x.c +++ b/src/dmm/bm25x.c @@ -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; diff --git a/src/dmm/dtm0660.c b/src/dmm/dtm0660.c index e10e773e..b23c04ab 100644 --- a/src/dmm/dtm0660.c +++ b/src/dmm/dtm0660.c @@ -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) diff --git a/src/dmm/es519xx.c b/src/dmm/es519xx.c index 4ebc293d..202b6485 100644 --- a/src/dmm/es519xx.c +++ b/src/dmm/es519xx.c @@ -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, diff --git a/src/dmm/fs9721.c b/src/dmm/fs9721.c index 17c75178..c13bdbcf 100644 --- a/src/dmm/fs9721.c +++ b/src/dmm/fs9721.c @@ -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) diff --git a/src/dmm/fs9922.c b/src/dmm/fs9922.c index b98d8ee2..292da6b5 100644 --- a/src/dmm/fs9922.c +++ b/src/dmm/fs9922.c @@ -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; } } diff --git a/src/dmm/metex14.c b/src/dmm/metex14.c index 0dd5d2ed..687df906 100644 --- a/src/dmm/metex14.c +++ b/src/dmm/metex14.c @@ -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) diff --git a/src/dmm/ut71x.c b/src/dmm/ut71x.c index 9a7d2eab..6dbf23a4 100644 --- a/src/dmm/ut71x.c +++ b/src/dmm/ut71x.c @@ -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) diff --git a/src/dmm/vc870.c b/src/dmm/vc870.c index b0095b41..2af7cc99 100644 --- a/src/dmm/vc870.c +++ b/src/dmm/vc870.c @@ -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, diff --git a/src/hardware/agilent-dmm/protocol.c b/src/hardware/agilent-dmm/protocol.c index 23768a6a..764136e8 100644 --- a/src/hardware/agilent-dmm/protocol.c +++ b/src/hardware/agilent-dmm/protocol.c @@ -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]; diff --git a/src/hardware/brymen-bm86x/protocol.c b/src/hardware/brymen-bm86x/protocol.c index 345fad57..097b8874 100644 --- a/src/hardware/brymen-bm86x/protocol.c +++ b/src/hardware/brymen-bm86x/protocol.c @@ -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; diff --git a/src/hardware/brymen-dmm/parser.c b/src/hardware/brymen-dmm/parser.c index 2f55cdf7..d42ff45a 100644 --- a/src/hardware/brymen-dmm/parser.c +++ b/src/hardware/brymen-dmm/parser.c @@ -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; diff --git a/src/hardware/fluke-dmm/protocol.c b/src/hardware/fluke-dmm/protocol.c index af4fd56c..a5d8cefe 100644 --- a/src/hardware/fluke-dmm/protocol.c +++ b/src/hardware/fluke-dmm/protocol.c @@ -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; diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c index 7d06b071..d1009b30 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.c +++ b/src/hardware/gmc-mh-1x-2x/protocol.c @@ -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; diff --git a/src/hardware/victor-dmm/protocol.c b/src/hardware/victor-dmm/protocol.c index 18b0cd1f..23dfe7ab 100644 --- a/src/hardware/victor-dmm/protocol.c +++ b/src/hardware/victor-dmm/protocol.c @@ -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 {