}
SR_PRIV int scpi_dmm_get_mq(const struct sr_dev_inst *sdi,
- enum sr_mq *mq, enum sr_mqflag *flag, char **rsp)
+ enum sr_mq *mq, enum sr_mqflag *flag, char **rsp,
+ const struct mqopt_item **mqitem)
{
struct dev_context *devc;
const char *command;
*flag = 0;
if (rsp)
*rsp = NULL;
+ if (mqitem)
+ *mqitem = NULL;
+ scpi_dmm_cmd_delay(sdi->conn);
command = sr_scpi_cmd_get(devc->cmdset, DMM_CMD_QUERY_FUNC);
if (!command || !*command)
return SR_ERR_NA;
response = NULL;
ret = sr_scpi_get_string(sdi->conn, command, &response);
- scpi_dmm_cmd_delay(sdi->conn);
if (ret != SR_OK)
return ret;
if (!response || !*response)
*mq = item->mq;
if (flag)
*flag = item->mqflag;
+ if (mqitem)
+ *mqitem = item;
ret = SR_OK;
}
mode = item->scpi_func_setup;
command = sr_scpi_cmd_get(devc->cmdset, DMM_CMD_SETUP_FUNC);
- ret = sr_scpi_send(sdi->conn, command, mode);
scpi_dmm_cmd_delay(sdi->conn);
+ ret = sr_scpi_send(sdi->conn, command, mode);
+ if (ret != SR_OK)
+ return ret;
- return ret;
+ return SR_OK;
}
SR_PRIV int scpi_dmm_get_meas_agilent(const struct sr_dev_inst *sdi, size_t ch)
* Get the meter's current mode, keep the response around.
* Skip the measurement if the mode is uncertain.
*/
- ret = scpi_dmm_get_mq(sdi, &mq, &mqflag, &mode_response);
+ ret = scpi_dmm_get_mq(sdi, &mq, &mqflag, &mode_response, &item);
if (ret != SR_OK) {
g_free(mode_response);
return ret;
snprintf(prec_text, sizeof(prec_text),
"%s", fields[count - 1]);
p = prec_text;
+ } else if (!item) {
+ p = NULL;
+ } else if (item->default_precision == NO_DFLT_PREC) {
+ p = NULL;
} else {
- item = scpi_dmm_lookup_mq_number(sdi, mq, mqflag);
- if (!item) {
- p = NULL;
- } else if (item->default_precision == NO_DFLT_PREC) {
- p = NULL;
- } else {
- snprintf(prec_text, sizeof(prec_text),
- "1e%d", item->default_precision);
- p = prec_text;
- }
+ snprintf(prec_text, sizeof(prec_text),
+ "1e%d", item->default_precision);
+ p = prec_text;
}
g_strfreev(fields);
command = sr_scpi_cmd_get(devc->cmdset, DMM_CMD_QUERY_VALUE);
if (!command || !*command)
return SR_ERR_NA;
- ret = sr_scpi_get_string(scpi, command, &response);
scpi_dmm_cmd_delay(scpi);
+ ret = sr_scpi_get_string(scpi, command, &response);
if (ret != SR_OK)
return ret;
g_strstrip(response);
case SR_MQ_FREQUENCY:
unit = SR_UNIT_HERTZ;
break;
+ case SR_MQ_TIME:
+ unit = SR_UNIT_SECOND;
+ break;
default:
return SR_ERR_NA;
}