X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=hardware%2Fcommon%2Fdmm%2Ffs9922.c;h=4e878ac63f4a717b00f55d2100984eee0ac7a8da;hb=7ab89f4827d516313cafc9b7b9670ee99dc9c584;hp=9218c73df88e3d8bf766daa54a707aa18765e5bc;hpb=913abe83214f68d1743c555aa3fbe112db48a0cb;p=libsigrok.git diff --git a/hardware/common/dmm/fs9922.c b/hardware/common/dmm/fs9922.c index 9218c73d..4e878ac6 100644 --- a/hardware/common/dmm/fs9922.c +++ b/hardware/common/dmm/fs9922.c @@ -29,14 +29,14 @@ #include "libsigrok.h" #include "libsigrok-internal.h" -/* Message logging helpers with driver-specific prefix string. */ -#define DRIVER_LOG_DOMAIN "fs9922: " -#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args) -#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args) -#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args) -#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args) -#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args) -#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args) +/* Message logging helpers with subsystem-specific prefix string. */ +#define LOG_PREFIX "fs9922: " +#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args) +#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args) +#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args) +#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args) +#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args) +#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args) static gboolean flags_valid(const struct fs9922_info *info) { @@ -54,9 +54,15 @@ static gboolean flags_valid(const struct fs9922_info *info) return FALSE; } - /* Does the packet "measure" more than one type of value? */ + /* + * Does the packet "measure" more than one type of value? + * + * Note: In "diode mode", both is_diode and is_volt will be set. + * That is a valid use-case, so we don't want to error out below + * if it happens. Thus, we don't check for is_diode here. + */ count = 0; - count += (info->is_diode) ? 1 : 0; + // count += (info->is_diode) ? 1 : 0; count += (info->is_percent) ? 1 : 0; count += (info->is_volt) ? 1 : 0; count += (info->is_ampere) ? 1 : 0; @@ -237,7 +243,8 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval, *floatval *= 1000000; /* Measurement modes */ - if (info->is_volt) { + if (info->is_volt || info->is_diode) { + /* Note: In "diode mode" both is_diode and is_volt are set. */ analog->mq = SR_MQ_VOLTAGE; analog->unit = SR_UNIT_VOLT; } @@ -272,11 +279,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval, if (info->is_beep) { analog->mq = SR_MQ_CONTINUITY; analog->unit = SR_UNIT_BOOLEAN; - *floatval = (*floatval < 0.0) ? 0.0 : 1.0; - } - if (info->is_diode) { - analog->mq = SR_MQ_VOLTAGE; - analog->unit = SR_UNIT_VOLT; + *floatval = (*floatval == INFINITY) ? 0.0 : 1.0; } if (info->is_percent) { analog->mq = SR_MQ_DUTY_CYCLE;