X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Ffluke-dmm%2Ffluke.c;h=edb6734adbd06166a1204cbd02012c16f77e060f;hb=d292f767bd031979edbcbf54b7daa39b0aad7812;hp=848e03e545309d848a0b54094e5730201d8c8af7;hpb=decfe89d4e8c0902c1ca56933f2da30b97e9fa72;p=libsigrok.git diff --git a/hardware/fluke-dmm/fluke.c b/hardware/fluke-dmm/fluke.c index 848e03e5..edb6734a 100644 --- a/hardware/fluke-dmm/fluke.c +++ b/hardware/fluke-dmm/fluke.c @@ -26,7 +26,6 @@ #include "libsigrok-internal.h" #include "fluke-dmm.h" - static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi, char **tokens) { @@ -41,10 +40,17 @@ static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi, if ((e = strstr(tokens[1], "Out of range"))) { is_oor = TRUE; fvalue = -1; + while(*e && *e != '.') + e++; } else { is_oor = FALSE; - fvalue = strtof(tokens[1], &e); - if (fvalue == 0.0 && e == tokens[1]) { + /* Delimit the float, since sr_atof_ascii() wants only + * a valid float here. */ + e = tokens[1]; + while(*e && *e != ' ') + e++; + *e++ = '\0'; + if (sr_atof_ascii(tokens[1], &fvalue) != SR_OK || fvalue == 0.0) { /* Happens all the time, when switching modes. */ sr_dbg("Invalid float."); return NULL; @@ -57,7 +63,7 @@ static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi, return NULL; if (!(analog->data = g_try_malloc(sizeof(float)))) return NULL; - analog->probes = sdi->probes; + analog->channels = sdi->channels; analog->num_samples = 1; if (is_oor) *analog->data = NAN; @@ -155,14 +161,12 @@ static struct sr_datafeed_analog *handle_qm_28x(const struct sr_dev_inst *sdi, { struct sr_datafeed_analog *analog; float fvalue; - char *eptr; if (!tokens[1]) return NULL; - fvalue = strtof(tokens[0], &eptr); - if (fvalue == 0.0 && eptr == tokens[0]) { - sr_err("Invalid float."); + if (sr_atof_ascii(tokens[0], &fvalue) != SR_OK || fvalue == 0.0) { + sr_err("Invalid float '%s'.", tokens[0]); return NULL; } @@ -170,7 +174,7 @@ static struct sr_datafeed_analog *handle_qm_28x(const struct sr_dev_inst *sdi, return NULL; if (!(analog->data = g_try_malloc(sizeof(float)))) return NULL; - analog->probes = sdi->probes; + analog->channels = sdi->channels; analog->num_samples = 1; *analog->data = fvalue; analog->mq = -1; @@ -364,7 +368,6 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens) struct sr_datafeed_packet packet; struct sr_datafeed_analog analog; float fvalue; - char *eptr; if (!strcmp(tokens[0], "9.9E+37")) { /* An invalid measurement shows up on the display as "OL", but @@ -372,8 +375,7 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens) * is rather problematic, we'll cut through this here. */ fvalue = NAN; } else { - fvalue = strtof(tokens[0], &eptr); - if (fvalue == 0.0 && eptr == tokens[0]) { + if (sr_atof_ascii(tokens[0], &fvalue) != SR_OK || fvalue == 0.0) { sr_err("Invalid float '%s'.", tokens[0]); return; } @@ -394,7 +396,7 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens) fvalue = 1.0; } - analog.probes = sdi->probes; + analog.channels = sdi->channels; analog.num_samples = 1; analog.data = &fvalue; analog.mq = devc->mq; @@ -433,7 +435,7 @@ static void handle_line(const struct sr_dev_inst *sdi) analog = NULL; tokens = g_strsplit(devc->buf, ",", 0); if (tokens[0]) { - if (devc->profile->model == FLUKE_187) { + if (devc->profile->model == FLUKE_187 || devc->profile->model == FLUKE_189) { devc->expect_response = FALSE; analog = handle_qm_18x(sdi, tokens); } else if (devc->profile->model == FLUKE_287) { @@ -532,5 +534,3 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data) return TRUE; } - -