}
memset(str, 0, sizeof(str));
- /* Spaces may interfere with strtod parsing the exponent. Strip them. */
- for (s = 0, d = 0; s < len; s++)
+ /* Spaces may interfere with parsing the exponent. Strip them. */
+ for (s = 0, d = 0; s < len; s++) {
if (strbuf[s] != ' ')
str[d++] = strbuf[s];
- /* Yes, it's that simple! */
- *floatval = strtod(str, NULL);
+ }
+ if (sr_atof_ascii(str, floatval) != SR_OK)
+ return SR_ERR;
return SR_OK;
}
info->is_ac = (buf[4 + 0] & (1 << 0)) != 0;
}
-SR_PRIV int sr_brymen_parse(const uint8_t *buf, float *floatval,
- struct sr_datafeed_analog *analog, void *info)
+SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
+ struct sr_datafeed_analog *analog, void *info)
{
struct brymen_flags flags;
struct brymen_header *hdr;
sr_dbg("DMM packet: \"%.*s\"", asciilen, bfunc + 4);
parse_flags(buf, &flags);
- parse_value((const char *)(bfunc + 4), asciilen, floatval);
+ if (parse_value((const char *)(bfunc + 4), asciilen, floatval) != SR_OK)
+ return SR_ERR;
if (flags.is_volt) {
analog->mq = SR_MQ_VOLTAGE;
analog.num_samples = 1;
analog.mq = -1;
- sr_brymen_parse(buf, &floatval, &analog, NULL);
+ if (brymen_parse(buf, &floatval, &analog, NULL) != SR_OK)
+ return;
analog.data = &floatval;
analog.probes = sdi->probes;
SR_PRIV int brymen_packet_length(const uint8_t *buf, int *len);
SR_PRIV gboolean brymen_packet_is_valid(const uint8_t *buf);
-SR_PRIV int sr_brymen_parse(const uint8_t *buf, float *floatval,
- struct sr_datafeed_analog *analog, void *info);
+SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
+ struct sr_datafeed_analog *analog, void *info);
SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
uint8_t *buf, size_t *buflen,