gboolean is_oor;
(void)sdi;
+
if (strcmp(tokens[0], "QM"))
return NULL;
fvalue = strtof(tokens[1], &e);
if (fvalue == 0.0 && e == tokens[1]) {
/* Happens all the time, when switching modes. */
- sr_dbg("fluke-dmm: invalid float");
+ sr_dbg("Invalid float.");
return NULL;
}
}
while(*e && *e == ' ')
e++;
+ /* TODO: Check malloc return value. */
analog = g_try_malloc0(sizeof(struct sr_datafeed_analog));
analog->num_samples = 1;
+ /* TODO: Check malloc return value. */
analog->data = g_try_malloc(sizeof(float));
if (is_oor)
*analog->data = NAN;
char *eptr;
(void)sdi;
+
fvalue = strtof(tokens[0], &eptr);
if (fvalue == 0.0 && eptr == tokens[0]) {
- sr_err("fluke-dmm: invalid float");
+ sr_err("Invalid float.");
return NULL;
}
+ /* TODO: Check malloc return value. */
analog = g_try_malloc0(sizeof(struct sr_datafeed_analog));
analog->num_samples = 1;
+ /* TODO: Check malloc return value. */
analog->data = g_try_malloc(sizeof(float));
*analog->data = fvalue;
analog->mq = -1;
*analog->data = NAN;
} else
analog->mq = -1;
- } if (!strcmp(tokens[1], "CEL") || !strcmp(tokens[1], "FAR")) {
+ } else if (!strcmp(tokens[1], "dBV") || !strcmp(tokens[1], "dBm")) {
+ analog->mq = SR_MQ_VOLTAGE;
+ if (tokens[1][2] == 'm')
+ analog->unit = SR_UNIT_DECIBEL_MW;
+ else
+ analog->unit = SR_UNIT_DECIBEL_VOLT;
+ analog->mqflags |= SR_MQFLAG_AC | SR_MQFLAG_RMS;
+ } else if (!strcmp(tokens[1], "CEL") || !strcmp(tokens[1], "FAR")) {
if (!strcmp(tokens[2], "NORMAL")) {
analog->mq = SR_MQ_TEMPERATURE;
if (tokens[1][0] == 'C')
else
analog->unit = SR_UNIT_FAHRENHEIT;
}
- } if (!strcmp(tokens[1], "OHM")) {
+ } else if (!strcmp(tokens[1], "OHM")) {
if (!strcmp(tokens[3], "NONE")) {
analog->mq = SR_MQ_RESISTANCE;
analog->unit = SR_UNIT_OHM;
analog->unit = SR_UNIT_BOOLEAN;
*analog->data = 1.0;
}
- } if (!strcmp(tokens[1], "F")
+ } else if (!strcmp(tokens[1], "F")
&& !strcmp(tokens[2], "NORMAL")
&& !strcmp(tokens[3], "NONE")) {
analog->mq = SR_MQ_CAPACITANCE;
} if (!strcmp(tokens[1], "Hz") && !strcmp(tokens[2], "NORMAL")) {
analog->mq = SR_MQ_FREQUENCY;
analog->unit = SR_UNIT_HERTZ;
- } if (!strcmp(tokens[1], "PCT") && !strcmp(tokens[2], "NORMAL")) {
+ } else if (!strcmp(tokens[1], "PCT") && !strcmp(tokens[2], "NORMAL")) {
analog->mq = SR_MQ_DUTY_CYCLE;
analog->unit = SR_UNIT_PERCENTAGE;
- } if (!strcmp(tokens[1], "S") && !strcmp(tokens[2], "NORMAL")) {
+ } else if (!strcmp(tokens[1], "S") && !strcmp(tokens[2], "NORMAL")) {
analog->mq = SR_MQ_PULSE_WIDTH;
analog->unit = SR_UNIT_SECOND;
- } if (!strcmp(tokens[1], "SIE") && !strcmp(tokens[2], "NORMAL")) {
+ } else if (!strcmp(tokens[1], "SIE") && !strcmp(tokens[2], "NORMAL")) {
analog->mq = SR_MQ_CONDUCTANCE;
analog->unit = SR_UNIT_SIEMENS;
}
char **tokens;
devc = sdi->priv;
- sr_spew("fluke-dmm: received line '%s' (%d)", devc->buf, devc->buflen);
+ sr_spew("Received line '%s' (%d).", devc->buf, devc->buflen);
if (devc->buflen == 1) {
if (devc->buf[0] != '0') {
/* Not just a CMD_ACK from the query command. */
- sr_dbg("fluke-dmm: got CMD_ACK '%c'", devc->buf[0]);
+ sr_dbg("Got CMD_ACK '%c'.", devc->buf[0]);
devc->expect_response = FALSE;
}
devc->buflen = 0;
SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data)
{
- const struct sr_dev_inst *sdi;
+ struct sr_dev_inst *sdi;
struct dev_context *devc;
int len;
int64_t now, elapsed;
+ (void)fd;
+
if (!(sdi = cb_data))
return TRUE;
if (revents == G_IO_IN) {
/* Serial data arrived. */
while(FLUKEDMM_BUFSIZE - devc->buflen - 1 > 0) {
- len = serial_read(fd, devc->buf + devc->buflen, 1);
+ len = serial_read(devc->serial, devc->buf + devc->buflen, 1);
if (len < 1)
break;
devc->buflen++;
* or temporary disconnect issues. */
if ((devc->expect_response == FALSE && elapsed > devc->profile->poll_period)
|| elapsed > 1000) {
- sr_spew("fluke-dmm: sending QM");
- if (serial_write(devc->serial->fd, "QM\r", 3) == -1)
- sr_err("fluke-dmm: unable to send QM: %s", strerror(errno));
+ sr_spew("Sending QM.");
+ if (serial_write(devc->serial, "QM\r", 3) == -1)
+ sr_err("Unable to send QM: %s.", strerror(errno));
devc->cmd_sent_at = now;
devc->expect_response = TRUE;
}