Unify the mm38xr package parser with the other drivers regarding the use of the
digits properties in the analog payload. This commit adjusts the previously
unclear, but now clarified, use of these properties:
Number of significant digits after the decimal point, if positive. When
negative, exponent with reversed polarity that is necessary to express the
value with all digits without a decimal point.
struct sr_datafeed_analog *analog, void *info)
{
gboolean is_overload, is_bad_jack;
struct sr_datafeed_analog *analog, void *info)
{
gboolean is_overload, is_bad_jack;
int digits;
struct meterman_info mi;
int digits;
struct meterman_info mi;
if (meterman_38xr_decode(buf, &mi) != SR_OK)
return SR_ERR;
if (meterman_38xr_decode(buf, &mi) != SR_OK)
return SR_ERR;
if (mi.meas_mode != MEAS_MODE_CONTINUITY) {
is_overload = mi.reading == METERMAN_DIGITS_OVERLOAD;
is_bad_jack = mi.reading == METERMAN_DIGITS_BAD_INPUT_JACK;
if (mi.meas_mode != MEAS_MODE_CONTINUITY) {
is_overload = mi.reading == METERMAN_DIGITS_OVERLOAD;
is_bad_jack = mi.reading == METERMAN_DIGITS_BAD_INPUT_JACK;
if (mi.rflag_h == 0x0a || mi.peakstatus == 0x0b)
analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
if (mi.meas_mode != MEAS_MODE_CONTINUITY) {
if (mi.rflag_h == 0x0a || mi.peakstatus == 0x0b)
analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
if (mi.meas_mode != MEAS_MODE_CONTINUITY) {
- digits = decimal_digits[mi.meas_mode][mi.rangecode];
- exponent = units_exponents[mi.meas_mode][mi.rangecode];
+ digits = units_exponents[mi.meas_mode][mi.rangecode] -
+ decimal_digits[mi.meas_mode][mi.rangecode];
*floatval = mi.reading;
if (meterman_38xr_is_negative(&mi)) {
*floatval *= -1.0f;
}
*floatval = mi.reading;
if (meterman_38xr_is_negative(&mi)) {
*floatval *= -1.0f;
}
- *floatval *= powf(10, -digits);
- *floatval *= powf(10, exponent);
+ *floatval *= powf(10, digits);
- analog->encoding->digits = 4;
- analog->spec->spec_digits = 4;
+ analog->encoding->digits = -digits;
+ analog->spec->spec_digits = -digits;