]> sigrok.org Git - libsigrok.git/commitdiff
scpi-dmm: move OPC availability check to after IDN device identification
authorGerhard Sittig <redacted>
Thu, 20 May 2021 21:08:19 +0000 (23:08 +0200)
committerGerhard Sittig <redacted>
Sat, 22 May 2021 06:35:11 +0000 (08:35 +0200)
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).

src/hardware/scpi-dmm/api.c
src/hardware/scpi-dmm/protocol.h

index 7e4b4e5b4f73d4c74e98bda762bf7d25799aa47f..7bd1db945de440ce07b94916b241f5b6fd54e567 100644 (file)
@@ -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),
                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),
        },
        {
                "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),
        },
        {
                "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),
        },
        {
                "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),
        },
        {
                "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),
        },
        {
                "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",
        },
        {
                "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). */
                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),
        },
        {
                "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),
        },
        {
                "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;
 
        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.");
        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;
        }
 
                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);
        sdi = g_malloc0(sizeof(*sdi));
        sdi->vendor = g_strdup(hw_info->manufacturer);
        sdi->model = g_strdup(hw_info->model);
index 5261168f3edba1daea4f4dd8a25e862bf1c7f230..6af9496940aab6d62b53d33741fa2080b79b878e 100644 (file)
@@ -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 */
        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 {
 };
 
 struct dev_context {