From: Gerhard Sittig Date: Thu, 20 May 2021 21:08:19 +0000 (+0200) Subject: scpi-dmm: move OPC availability check to after IDN device identification X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=cae328b54c7b9679bafa6cd4fb00eb0f5894e8a3 scpi-dmm: move OPC availability check to after IDN device identification Assume that *IDN? requests don't involve expensive processing, and thus don't require *OPC? before their execution. This makes scpi-dmm follow the good tradition to only use non-standard or model dependent features after the device was successfully identified. Which avoids confusion on unrelated devices. Exclusively check for *OPC? availability on Owon devices, because these motivated the introduction of the test in the first place. This avoids confusion on other devices where short timeouts result in errors because the response is not retrieved although the command is supported (observed on Agilent meters connected via USBTMC). --- diff --git a/src/hardware/scpi-dmm/api.c b/src/hardware/scpi-dmm/api.c index 7e4b4e5b..7bd1db94 100644 --- a/src/hardware/scpi-dmm/api.c +++ b/src/hardware/scpi-dmm/api.c @@ -191,42 +191,42 @@ SR_PRIV const struct scpi_dmm_model models[] = { 1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a), scpi_dmm_get_meas_agilent, ARRAY_AND_SIZE(devopts_generic), - 0, 0, + 0, 0, FALSE, }, { "Agilent", "34410A", 1, 6, cmdset_hp, ARRAY_AND_SIZE(mqopts_agilent_34405a), scpi_dmm_get_meas_agilent, ARRAY_AND_SIZE(devopts_generic), - 0, 0, + 0, 0, FALSE, }, { "GW", "GDM8251A", 1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a), scpi_dmm_get_meas_gwinstek, ARRAY_AND_SIZE(devopts_generic), - 1000 * 2500, 0, + 1000 * 2500, 0, FALSE, }, { "GW", "GDM8255A", 1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a), scpi_dmm_get_meas_gwinstek, ARRAY_AND_SIZE(devopts_generic), - 1000 * 2500, 0, + 1000 * 2500, 0, FALSE, }, { "GWInstek", "GDM9060", 1, 6, cmdset_gwinstek_906x, ARRAY_AND_SIZE(mqopts_gwinstek_gdm906x), scpi_dmm_get_meas_agilent, ARRAY_AND_SIZE(devopts_generic), - 0, 0, + 0, 0, FALSE, }, { "GWInstek", "GDM9061", 1, 6, cmdset_gwinstek_906x, ARRAY_AND_SIZE(mqopts_gwinstek_gdm906x), scpi_dmm_get_meas_agilent, ARRAY_AND_SIZE(devopts_generic), - 0, 0, + 0, 0, FALSE, }, { "HP", "34401A", @@ -234,21 +234,21 @@ SR_PRIV const struct scpi_dmm_model models[] = { scpi_dmm_get_meas_agilent, ARRAY_AND_SIZE(devopts_generic), /* 34401A: typ. 1020ms for AC readings (default is 1000ms). */ - 1000 * 1500, 0, + 1000 * 1500, 0, FALSE, }, { "Keysight", "34465A", 1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a), scpi_dmm_get_meas_agilent, ARRAY_AND_SIZE(devopts_generic), - 0, 0, + 0, 0, FALSE, }, { "OWON", "XDM2041", 1, 5, cmdset_owon, ARRAY_AND_SIZE(mqopts_owon_xdm2041), scpi_dmm_get_meas_gwinstek, ARRAY_AND_SIZE(devopts_generic), - 0, 1e9, + 0, 1e9, TRUE, }, }; @@ -302,10 +302,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) gchar *channel_name; const char *command; - if (!probe_opc_support(scpi)) - scpi->no_opc_command = TRUE; - - scpi_dmm_cmd_delay(scpi); ret = sr_scpi_get_hw_id(scpi, &hw_info); if (ret != SR_OK) { sr_info("Could not get IDN response."); @@ -318,6 +314,9 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) return NULL; } + if (model->check_opc && !probe_opc_support(scpi)) + scpi->no_opc_command = TRUE; + sdi = g_malloc0(sizeof(*sdi)); sdi->vendor = g_strdup(hw_info->manufacturer); sdi->model = g_strdup(hw_info->model); diff --git a/src/hardware/scpi-dmm/protocol.h b/src/hardware/scpi-dmm/protocol.h index 5261168f..6af94969 100644 --- a/src/hardware/scpi-dmm/protocol.h +++ b/src/hardware/scpi-dmm/protocol.h @@ -65,6 +65,7 @@ struct scpi_dmm_model { size_t devopts_size; unsigned int read_timeout_us; /* If zero, use default from src/scpi/scpi.c. */ float infinity_limit; /* If zero, use default from protocol.c */ + gboolean check_opc; }; struct dev_context {