/*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
*
* Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
*
#include "libsigrok-internal.h"
#include "fluke-dmm.h"
-
static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi,
char **tokens)
{
char *e, *u;
gboolean is_oor;
- (void)sdi;
-
if (strcmp(tokens[0], "QM") || !tokens[1])
return NULL;
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;
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;
{
struct sr_datafeed_analog *analog;
float fvalue;
- char *eptr;
-
- (void)sdi;
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;
}
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;
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
* 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;
}
fvalue = 1.0;
}
- analog.probes = sdi->probes;
+ analog.channels = sdi->channels;
analog.num_samples = 1;
analog.data = &fvalue;
analog.mq = devc->mq;
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) {
return TRUE;
}
-
-