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.
This commit is contained in:
Gerhard Sittig 2018-02-04 22:26:23 +01:00 committed by Uwe Hermann
parent b8278e0943
commit 64aa214a22
15 changed files with 22 additions and 20 deletions

View 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)

View 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;

View 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)

View 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,

View 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)

View 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;
}
}

View 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)

View 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)

View 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,

View 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];

View 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;

View 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;

View 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;

View 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;

View 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 {