#include <stdlib.h>
#include <math.h>
#include <string.h>
-#include <errno.h>
#include <glib.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#include "fluke-dmm.h"
if ((e = strstr(tokens[1], "Out of range"))) {
is_oor = TRUE;
fvalue = -1;
- while(*e && *e != '.')
+ while (*e && *e != '.')
e++;
} else {
is_oor = FALSE;
/* Delimit the float, since sr_atof_ascii() wants only
* a valid float here. */
e = tokens[1];
- while(*e && *e != ' ')
+ while (*e && *e != ' ')
e++;
*e++ = '\0';
if (sr_atof_ascii(tokens[1], &fvalue) != SR_OK || fvalue == 0.0) {
return NULL;
}
}
- while(*e && *e == ' ')
+ while (*e && *e == ' ')
e++;
- if (!(analog = g_try_malloc0(sizeof(struct sr_datafeed_analog))))
- return NULL;
- if (!(analog->data = g_try_malloc(sizeof(float))))
- return NULL;
+ analog = g_malloc0(sizeof(struct sr_datafeed_analog));
+ analog->data = g_malloc(sizeof(float));
analog->channels = sdi->channels;
analog->num_samples = 1;
if (is_oor)
return NULL;
}
- if (!(analog = g_try_malloc0(sizeof(struct sr_datafeed_analog))))
- return NULL;
- if (!(analog->data = g_try_malloc(sizeof(float))))
- return NULL;
+ analog = g_malloc0(sizeof(struct sr_datafeed_analog));
+ analog->data = g_malloc(sizeof(float));
analog->channels = sdi->channels;
analog->num_samples = 1;
*analog->data = fvalue;
/* Don't have valid metadata yet. */
return;
-
if (devc->mq == SR_MQ_RESISTANCE && isnan(fvalue))
fvalue = INFINITY;
else if (devc->mq == SR_MQ_CONTINUITY) {
/* Slip the request in now, before the main
* timer loop asks for metadata again. */
n = sprintf(cmd, "QM %d\r", devc->meas_type);
- if (serial_write_blocking(serial, cmd, n, 0) < 0)
+ if (serial_write_blocking(serial, cmd, n, SERIAL_WRITE_TIMEOUT_MS) < 0)
sr_err("Unable to send QM (measurement).");
}
} else {
serial = sdi->conn;
if (revents == G_IO_IN) {
/* Serial data arrived. */
- while(FLUKEDMM_BUFSIZE - devc->buflen - 1 > 0) {
+ while (FLUKEDMM_BUFSIZE - devc->buflen - 1 > 0) {
len = serial_read_nonblocking(serial, devc->buf + devc->buflen, 1);
if (len < 1)
break;
* out-of-sync or temporary disconnect issues. */
if ((devc->expect_response == FALSE && elapsed > devc->profile->poll_period)
|| elapsed > devc->profile->timeout) {
- if (serial_write_blocking(serial, "QM\r", 3, 0) < 0)
+ if (serial_write_blocking(serial, "QM\r", 3, SERIAL_WRITE_TIMEOUT_MS) < 0)
sr_err("Unable to send QM.");
devc->cmd_sent_at = now;
devc->expect_response = TRUE;