X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ffluke-dmm%2Fprotocol.c;h=d8837f661c1efc45049eaf529ba1ce52c470cfbb;hb=b1fa9aac740d8fb2d6aaad8974e06680a817524c;hp=212e4c401e49e3f085a58a8a427228b014f34cc6;hpb=d9a026ea7d1100b781641615730680113bec31ed;p=libsigrok.git diff --git a/src/hardware/fluke-dmm/protocol.c b/src/hardware/fluke-dmm/protocol.c index 212e4c40..d8837f66 100644 --- a/src/hardware/fluke-dmm/protocol.c +++ b/src/hardware/fluke-dmm/protocol.c @@ -206,17 +206,37 @@ static void handle_qm_28x(const struct sr_dev_inst *sdi, char **tokens) struct sr_analog_spec spec; float fvalue; int digits; + int exponent; + char *e; devc = sdi->priv; if (!tokens[1]) return; + /* Split measurement into mantissa / exponent */ + e = tokens[0]; + while (*e) { + if (*e == 'e' || *e == 'E') { + *e = '\0'; + e++; + break; + } + e++; + } + if (sr_atof_ascii(tokens[0], &fvalue) != SR_OK) { - sr_err("Invalid float '%s'.", tokens[0]); + sr_err("Invalid mantissa '%s'.", tokens[0]); return; } - digits = count_digits(tokens[0]); + + if (sr_atoi(e, &exponent) != SR_OK) { + sr_err("Invalid exponent '%s'.", e); + return; + } + + digits = count_digits(tokens[0]) - exponent; + fvalue *= pow(10.0f, exponent); sr_analog_init(&analog, &encoding, &meaning, &spec, digits); analog.data = &fvalue;