From: Gerhard Sittig Date: Fri, 21 May 2021 16:37:05 +0000 (+0200) Subject: scpi-dmm: avoid get/set range calls for some of the Agilent DMM functions X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5bf642dbf80b8070b238ec1d83454e677cb2336b;p=libsigrok.git scpi-dmm: avoid get/set range calls for some of the Agilent DMM functions While queries for the range are supported for voltage, current, resistence, capacitance, the same queries in temperature, frequency, diode, continuity modes not only fail but even lose the USB connection to the device. This was consistently observed with 34405A and 34465A. Suppress get and set range requests for the known problematic modes of the Agilent protocol speaking meters. --- diff --git a/src/hardware/scpi-dmm/api.c b/src/hardware/scpi-dmm/api.c index 0d3c6735..b13d8f6d 100644 --- a/src/hardware/scpi-dmm/api.c +++ b/src/hardware/scpi-dmm/api.c @@ -133,11 +133,11 @@ static const struct mqopt_item mqopts_agilent_34405a[] = { { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "CURR:AC ", NO_DFLT_PREC, FLAGS_NONE, }, { SR_MQ_RESISTANCE, 0, "RES", "RES ", NO_DFLT_PREC, FLAGS_NONE, }, { SR_MQ_RESISTANCE, SR_MQFLAG_FOUR_WIRE, "FRES", "FRES ", NO_DFLT_PREC, FLAGS_NONE, }, - { SR_MQ_CONTINUITY, 0, "CONT", "CONT", -1, FLAGS_NONE, }, + { SR_MQ_CONTINUITY, 0, "CONT", "CONT", -1, FLAG_NO_RANGE, }, { SR_MQ_CAPACITANCE, 0, "CAP", "CAP ", NO_DFLT_PREC, FLAGS_NONE, }, - { SR_MQ_VOLTAGE, SR_MQFLAG_DC | SR_MQFLAG_DIODE, "DIOD", "DIOD", -4, FLAGS_NONE, }, - { SR_MQ_TEMPERATURE, 0, "TEMP", "TEMP ", NO_DFLT_PREC, FLAGS_NONE, }, - { SR_MQ_FREQUENCY, 0, "FREQ", "FREQ ", NO_DFLT_PREC, FLAGS_NONE, }, + { SR_MQ_VOLTAGE, SR_MQFLAG_DC | SR_MQFLAG_DIODE, "DIOD", "DIOD", -4, FLAG_NO_RANGE, }, + { SR_MQ_TEMPERATURE, 0, "TEMP", "TEMP ", NO_DFLT_PREC, FLAG_NO_RANGE, }, + { SR_MQ_FREQUENCY, 0, "FREQ", "FREQ ", NO_DFLT_PREC, FLAG_NO_RANGE, }, }; static const struct mqopt_item mqopts_agilent_34401a[] = { diff --git a/src/hardware/scpi-dmm/protocol.c b/src/hardware/scpi-dmm/protocol.c index 8c7b3373..97a783fe 100644 --- a/src/hardware/scpi-dmm/protocol.c +++ b/src/hardware/scpi-dmm/protocol.c @@ -171,6 +171,8 @@ SR_PRIV const char *scpi_dmm_get_range_text(const struct sr_dev_inst *sdi) return NULL; if (!mqitem || !mqitem->scpi_func_setup) return NULL; + if (mqitem->drv_flags & FLAG_NO_RANGE) + return NULL; scpi_dmm_cmd_delay(sdi->conn); ret = sr_scpi_cmd(sdi, devc->cmdset, 0, NULL, @@ -230,6 +232,8 @@ SR_PRIV int scpi_dmm_set_range_from_text(const struct sr_dev_inst *sdi, return ret; if (!item || !item->scpi_func_setup) return SR_ERR_ARG; + if (item->drv_flags & FLAG_NO_RANGE) + return SR_ERR_NA; is_auto = g_ascii_strcasecmp(range, "auto") == 0; scpi_dmm_cmd_delay(sdi->conn); diff --git a/src/hardware/scpi-dmm/protocol.h b/src/hardware/scpi-dmm/protocol.h index 5fa0ba6f..04b8e683 100644 --- a/src/hardware/scpi-dmm/protocol.h +++ b/src/hardware/scpi-dmm/protocol.h @@ -57,6 +57,7 @@ struct mqopt_item { }; #define NO_DFLT_PREC -99 #define FLAGS_NONE 0 +#define FLAG_NO_RANGE (1 << 0) struct scpi_dmm_model { const char *vendor;