]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-dmm/api.c
scpi-dmm: Add support for Agilent 34460A
[libsigrok.git] / src / hardware / scpi-dmm / api.c
index 3098a95f31543fbd5ee8fd78fc62fe6316e89f9b..520dc7068a7c11c647f159b49167587aa626ce5f 100644 (file)
@@ -33,19 +33,32 @@ static const uint32_t drvopts[] = {
 
 static const uint32_t devopts_generic[] = {
        SR_CONF_CONTINUOUS,
+       SR_CONF_CONN | SR_CONF_GET,
        SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_MEASURED_QUANTITY | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
 };
 
+static const uint32_t devopts_generic_range[] = {
+       SR_CONF_CONTINUOUS,
+       SR_CONF_CONN | SR_CONF_GET,
+       SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_MEASURED_QUANTITY | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_RANGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+};
+
 static const struct scpi_command cmdset_agilent[] = {
        { DMM_CMD_SETUP_REMOTE, "\n", },
        { DMM_CMD_SETUP_FUNC, "CONF:%s", },
        { DMM_CMD_QUERY_FUNC, "CONF?", },
-       { DMM_CMD_START_ACQ, "MEAS", },
+       { DMM_CMD_START_ACQ, "INIT", },
        { DMM_CMD_STOP_ACQ, "ABORT", },
-       { DMM_CMD_QUERY_VALUE, "READ?", },
+       { DMM_CMD_QUERY_VALUE, "FETCH?", },
        { DMM_CMD_QUERY_PREC, "CONF?", },
+       { DMM_CMD_QUERY_RANGE_AUTO, "%s:RANGE:AUTO?", },
+       { DMM_CMD_QUERY_RANGE, "%s:RANGE?", },
+       { DMM_CMD_SETUP_RANGE, "CONF:%s %s", },
        ALL_ZERO,
 };
 
@@ -82,56 +95,107 @@ static const struct scpi_command cmdset_hp[] = {
 
 static const struct scpi_command cmdset_gwinstek[] = {
        { DMM_CMD_SETUP_REMOTE, "SYST:REM", },
+       { DMM_CMD_SETUP_LOCAL, "SYST:LOC", },
        { DMM_CMD_SETUP_FUNC, "CONF:%s", },
        { DMM_CMD_QUERY_FUNC, "CONF:STAT:FUNC?", },
        { DMM_CMD_START_ACQ, "*CLS;SYST:REM", },
-       { DMM_CMD_STOP_ACQ, "SYST:LOC", },
        { DMM_CMD_QUERY_VALUE, "VAL1?", },
        { DMM_CMD_QUERY_PREC, "SENS:DET:RATE?", },
        ALL_ZERO,
 };
 
+static const struct scpi_command cmdset_gwinstek_906x[] = {
+       { DMM_CMD_SETUP_REMOTE, "SYST:REM", },
+       { DMM_CMD_SETUP_LOCAL, "SYST:LOC", },
+       { DMM_CMD_SETUP_FUNC, "CONF:%s", },
+       { DMM_CMD_QUERY_FUNC, "CONF?", },
+       { DMM_CMD_START_ACQ, "INIT", },
+       { DMM_CMD_STOP_ACQ, "ABORT", },
+       { DMM_CMD_QUERY_VALUE, "VAL1?", },
+       { DMM_CMD_QUERY_PREC, "SENS:DET:RATE?", },
+       ALL_ZERO,
+};
+
+static const struct scpi_command cmdset_owon[] = {
+       { DMM_CMD_SETUP_REMOTE, "SYST:REM", },
+       { DMM_CMD_SETUP_LOCAL, "SYST:LOC", },
+       { DMM_CMD_SETUP_FUNC, "CONF:%s", },
+       { DMM_CMD_QUERY_FUNC, "FUNC?", },
+       { DMM_CMD_QUERY_VALUE, "MEAS1?", },
+       ALL_ZERO,
+};
+
 static const struct mqopt_item mqopts_agilent_34405a[] = {
-       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "VOLT ", NO_DFLT_PREC, },
-       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "VOLT:AC ", NO_DFLT_PREC, },
-       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "CURR ", NO_DFLT_PREC, },
-       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "CURR:AC ", NO_DFLT_PREC, },
-       { SR_MQ_RESISTANCE, 0, "RES", "RES ", NO_DFLT_PREC, },
-       { SR_MQ_CONTINUITY, 0, "CONT", "CONT", -1, },
-       { SR_MQ_CAPACITANCE, 0, "CAP", "CAP ", NO_DFLT_PREC, },
-       { SR_MQ_VOLTAGE, SR_MQFLAG_DC | SR_MQFLAG_DIODE, "DIOD", "DIOD", -4, },
-       { SR_MQ_TEMPERATURE, 0, "TEMP", "TEMP ", NO_DFLT_PREC, },
-       { SR_MQ_FREQUENCY, 0, "FREQ", "FREQ ", NO_DFLT_PREC, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "VOLT ", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "VOLT:AC ", NO_DFLT_PREC, FLAG_CONF_DELAY | FLAG_MEAS_DELAY, },
+       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "CURR ", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "CURR:AC ", NO_DFLT_PREC, FLAG_CONF_DELAY | FLAG_MEAS_DELAY, },
+       { SR_MQ_RESISTANCE, 0, "RES", "RES ", NO_DFLT_PREC, FLAG_MEAS_DELAY, },
+       { SR_MQ_RESISTANCE, SR_MQFLAG_FOUR_WIRE, "FRES", "FRES ", NO_DFLT_PREC, FLAG_MEAS_DELAY, },
+       { 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, FLAG_NO_RANGE, },
+       { SR_MQ_TEMPERATURE, 0, "TEMP", "TEMP ", NO_DFLT_PREC, FLAG_NO_RANGE | FLAG_MEAS_DELAY, },
+       { SR_MQ_FREQUENCY, 0, "FREQ", "FREQ ", NO_DFLT_PREC, FLAG_NO_RANGE | FLAG_MEAS_DELAY, },
 };
 
 static const struct mqopt_item mqopts_agilent_34401a[] = {
-       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "VOLT ", NO_DFLT_PREC, },
-       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "VOLT:AC ", NO_DFLT_PREC, },
-       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "CURR ", NO_DFLT_PREC, },
-       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "CURR:AC ", NO_DFLT_PREC, },
-       { SR_MQ_RESISTANCE, 0, "RES", "RES ", NO_DFLT_PREC, },
-       { SR_MQ_RESISTANCE, SR_MQFLAG_FOUR_WIRE, "FRES", "FRES ", NO_DFLT_PREC, },
-       { SR_MQ_CONTINUITY, 0, "CONT", "CONT", -1, },
-       { SR_MQ_VOLTAGE, SR_MQFLAG_DC | SR_MQFLAG_DIODE, "DIOD", "DIOD", -4, },
-       { SR_MQ_FREQUENCY, 0, "FREQ", "FREQ ", NO_DFLT_PREC, },
-       { SR_MQ_TIME, 0, "PER", "PER ", NO_DFLT_PREC, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "VOLT ", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "VOLT:AC ", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "CURR ", NO_DFLT_PREC, FLAGS_NONE, },
+       { 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_VOLTAGE, SR_MQFLAG_DC | SR_MQFLAG_DIODE, "DIOD", "DIOD", -4, FLAGS_NONE, },
+       { SR_MQ_FREQUENCY, 0, "FREQ", "FREQ ", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_TIME, 0, "PER", "PER ", NO_DFLT_PREC, FLAGS_NONE, },
 };
 
 static const struct mqopt_item mqopts_gwinstek_gdm8200a[] = {
-       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "01", NO_DFLT_PREC, },
-       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "02", NO_DFLT_PREC, },
-       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "03", NO_DFLT_PREC, },
-       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "04", NO_DFLT_PREC, },
-       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "05", NO_DFLT_PREC, }, /* mA */
-       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "06", NO_DFLT_PREC, }, /* mA */
-       { SR_MQ_RESISTANCE, 0, "RES", "07", NO_DFLT_PREC, },
-       { SR_MQ_RESISTANCE, SR_MQFLAG_FOUR_WIRE, "FRES", "16", NO_DFLT_PREC, },
-       { SR_MQ_CONTINUITY, 0, "CONT", "13", -1, },
-       { SR_MQ_VOLTAGE, SR_MQFLAG_DC | SR_MQFLAG_DIODE, "DIOD", "17", -4, },
-       { SR_MQ_TEMPERATURE, 0, "TEMP", "09", NO_DFLT_PREC, }, /* Celsius */
-       { SR_MQ_TEMPERATURE, 0, "TEMP", "15", NO_DFLT_PREC, }, /* Fahrenheit */
-       { SR_MQ_FREQUENCY, 0, "FREQ", "08", NO_DFLT_PREC, },
-       { SR_MQ_TIME, 0, "PER", "14", NO_DFLT_PREC, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "01", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "02", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "03", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "04", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "05", NO_DFLT_PREC, FLAGS_NONE, }, /* mA */
+       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "06", NO_DFLT_PREC, FLAGS_NONE, }, /* mA */
+       { SR_MQ_RESISTANCE, 0, "RES", "07", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_RESISTANCE, SR_MQFLAG_FOUR_WIRE, "FRES", "16", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CONTINUITY, 0, "CONT", "13", -1, FLAGS_NONE, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_DC | SR_MQFLAG_DIODE, "DIOD", "17", -4, FLAGS_NONE, },
+       { SR_MQ_TEMPERATURE, 0, "TEMP", "09", NO_DFLT_PREC, FLAGS_NONE, }, /* Celsius */
+       { SR_MQ_TEMPERATURE, 0, "TEMP", "15", NO_DFLT_PREC, FLAGS_NONE, }, /* Fahrenheit */
+       { SR_MQ_FREQUENCY, 0, "FREQ", "08", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_TIME, 0, "PER", "14", NO_DFLT_PREC, FLAGS_NONE, },
+};
+
+static const struct mqopt_item mqopts_gwinstek_gdm906x[] = {
+       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "VOLT ", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "VOLT:AC", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "CURR ", NO_DFLT_PREC, FLAGS_NONE, },
+       { 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_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_TIME, 0, "PER", "PER", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CAPACITANCE, 0, "CAP", "CAP", NO_DFLT_PREC, FLAGS_NONE, },
+};
+
+static const struct mqopt_item mqopts_owon_xdm2041[] = {
+       { SR_MQ_VOLTAGE, SR_MQFLAG_AC, "VOLT:AC", "VOLT AC", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_VOLTAGE, SR_MQFLAG_DC, "VOLT:DC", "VOLT", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_AC, "CURR:AC", "CURR AC", NO_DFLT_PREC, FLAGS_NONE, },
+       { SR_MQ_CURRENT, SR_MQFLAG_DC, "CURR:DC", "CURR", 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_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_CAPACITANCE, 0, "CAP", "CAP", NO_DFLT_PREC, FLAGS_NONE, },
 };
 
 SR_PRIV const struct scpi_dmm_model models[] = {
@@ -139,22 +203,57 @@ SR_PRIV const struct scpi_dmm_model models[] = {
                "Agilent", "34405A",
                1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a),
                scpi_dmm_get_meas_agilent,
-               ARRAY_AND_SIZE(devopts_generic),
-               0,
+               ARRAY_AND_SIZE(devopts_generic_range),
+               0, 200 * 1000, 2500 * 1000, 0, FALSE,
+               scpi_dmm_get_range_text, scpi_dmm_set_range_from_text, NULL,
        },
        {
                "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, 0, FALSE,
+               NULL, NULL, NULL,
        },
        {
-               "Keysight", "34465A",
-               1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a),
+               "Agilent", "34460A",
+               1, 6, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a),
+               scpi_dmm_get_meas_agilent,
+               ARRAY_AND_SIZE(devopts_generic_range),
+               0, 0, 10 * 1000, 0, FALSE,
+               scpi_dmm_get_range_text, scpi_dmm_set_range_from_text, NULL,
+       },
+       {
+               "GW", "GDM8251A",
+               1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a),
+               scpi_dmm_get_meas_gwinstek,
+               ARRAY_AND_SIZE(devopts_generic),
+               2500 * 1000, 0, 0, 0, FALSE,
+               NULL, NULL, NULL,
+       },
+       {
+               "GW", "GDM8255A",
+               1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a),
+               scpi_dmm_get_meas_gwinstek,
+               ARRAY_AND_SIZE(devopts_generic),
+               2500 * 1000, 0, 0, 0, FALSE,
+               NULL, NULL, NULL,
+       },
+       {
+               "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, 0, FALSE,
+               NULL, NULL, NULL,
+       },
+       {
+               "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,
+               NULL, NULL, NULL,
        },
        {
                "HP", "34401A",
@@ -162,21 +261,24 @@ 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,
+               1500 * 1000, 0, 0, 0, FALSE,
+               NULL, NULL, NULL,
        },
        {
-               "GW", "GDM8251A",
-               1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a),
-               scpi_dmm_get_meas_gwinstek,
-               ARRAY_AND_SIZE(devopts_generic),
-               1000 * 2500,
+               "Keysight", "34465A",
+               1, 6, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a),
+               scpi_dmm_get_meas_agilent,
+               ARRAY_AND_SIZE(devopts_generic_range),
+               0, 0, 10 * 1000, 0, FALSE,
+               scpi_dmm_get_range_text, scpi_dmm_set_range_from_text, NULL,
        },
        {
-               "GW", "GDM8255A",
-               1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a),
+               "OWON", "XDM2041",
+               1, 5, cmdset_owon, ARRAY_AND_SIZE(mqopts_owon_xdm2041),
                scpi_dmm_get_meas_gwinstek,
                ARRAY_AND_SIZE(devopts_generic),
-               1000 * 2500,
+               0, 0, 0, 1e9, TRUE,
+               NULL, NULL, NULL,
        },
 };
 
@@ -199,6 +301,25 @@ static const struct scpi_dmm_model *is_compatible(const char *vendor, const char
        return NULL;
 }
 
+/*
+ * Some devices (such as Owon XDM2041) do not support the standard
+ * OPeration Complete? command. This function tests the command with
+ * a short timeout, and returns TRUE if any reply (busy or not) is received.
+ */
+static gboolean probe_opc_support(struct sr_scpi_dev_inst *scpi)
+{
+       gboolean result;
+       GString *response;
+
+       response = g_string_sized_new(128);
+       result = TRUE;
+       if (sr_scpi_get_data(scpi, SCPI_CMD_OPC, &response) != SR_OK)
+               result = FALSE;
+       g_string_free(response, TRUE);
+
+       return result;
+}
+
 static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
 {
        struct sr_scpi_hw_info *hw_info;
@@ -209,8 +330,8 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        struct dev_context *devc;
        size_t i;
        gchar *channel_name;
+       const char *command;
 
-       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.");
@@ -223,6 +344,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);
@@ -231,6 +355,11 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        sdi->conn = scpi;
        sdi->driver = &scpi_dmm_driver_info;
        sdi->inst_type = SR_INST_SCPI;
+       ret = sr_scpi_connection_id(scpi, &sdi->connection_id);
+       if (ret != SR_OK) {
+               g_free(sdi->connection_id);
+               sdi->connection_id = NULL;
+       }
        sr_scpi_hw_info_free(hw_info);
        if (model->read_timeout_us)  /* non-default read timeout */
                scpi->read_timeout_us = model->read_timeout_us;
@@ -239,13 +368,22 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        devc->num_channels = model->num_channels;
        devc->cmdset = model->cmdset;
        devc->model = model;
-       devc->precision = NULL;
 
        for (i = 0; i < devc->num_channels; i++) {
                channel_name = g_strdup_printf("P%zu", i + 1);
                sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, channel_name);
        }
 
+       /*
+        * If device has DMM_CMD_SETUP_LOCAL command, send it now. To avoid
+        * leaving device in remote mode (if only a "scan" is run).
+        */
+       command = sr_scpi_cmd_get(devc->cmdset, DMM_CMD_SETUP_LOCAL);
+       if (command && *command) {
+               scpi_dmm_cmd_delay(scpi);
+               sr_scpi_send(scpi, command);
+       }
+
        return sdi;
 }
 
@@ -271,8 +409,11 @@ static int dev_open(struct sr_dev_inst *sdi)
 
 static int dev_close(struct sr_dev_inst *sdi)
 {
+       struct dev_context *devc;
        struct sr_scpi_dev_inst *scpi;
+       const char *command;
 
+       devc = sdi->priv;
        scpi = sdi->conn;
        if (!scpi)
                return SR_ERR_BUG;
@@ -281,6 +422,16 @@ static int dev_close(struct sr_dev_inst *sdi)
        if (sdi->status <= SR_ST_INACTIVE)
                return SR_OK;
 
+       /*
+        * If device has DMM_CMD_SETUP_LOCAL command, send it now
+        * to avoid leaving device in remote mode.
+        */
+       command = sr_scpi_cmd_get(devc->cmdset, DMM_CMD_SETUP_LOCAL);
+       if (command && *command) {
+               scpi_dmm_cmd_delay(scpi);
+               sr_scpi_send(scpi, command);
+       }
+
        return sr_scpi_close(scpi);
 }
 
@@ -292,12 +443,18 @@ static int config_get(uint32_t key, GVariant **data,
        enum sr_mqflag mqflag;
        GVariant *arr[2];
        int ret;
+       const char *range;
 
        (void)cg;
 
        devc = sdi->priv;
 
        switch (key) {
+       case SR_CONF_CONN:
+               if (!sdi || !sdi->connection_id)
+                       return SR_ERR_NA;
+               *data = g_variant_new_string(sdi->connection_id);
+               return SR_OK;
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
                return sr_sw_limits_config_get(&devc->limits, key, data);
@@ -309,6 +466,14 @@ static int config_get(uint32_t key, GVariant **data,
                arr[1] = g_variant_new_uint64(mqflag);
                *data = g_variant_new_tuple(arr, ARRAY_SIZE(arr));
                return SR_OK;
+       case SR_CONF_RANGE:
+               if (!devc || !devc->model->get_range_text)
+                       return SR_ERR_NA;
+               range = devc->model->get_range_text(sdi);
+               if (!range || !*range)
+                       return SR_ERR_NA;
+               *data = g_variant_new_string(range);
+               return SR_OK;
        default:
                return SR_ERR_NA;
        }
@@ -321,6 +486,7 @@ static int config_set(uint32_t key, GVariant *data,
        enum sr_mq mq;
        enum sr_mqflag mqflag;
        GVariant *tuple_child;
+       const char *range;
 
        (void)cg;
 
@@ -338,6 +504,11 @@ static int config_set(uint32_t key, GVariant *data,
                mqflag = g_variant_get_uint64(tuple_child);
                g_variant_unref(tuple_child);
                return scpi_dmm_set_mq(sdi, mq, mqflag);
+       case SR_CONF_RANGE:
+               if (!devc || !devc->model->set_range_from_text)
+                       return SR_ERR_NA;
+               range = g_variant_get_string(data, NULL);
+               return devc->model->set_range_from_text(sdi, range);
        default:
                return SR_ERR_NA;
        }
@@ -377,6 +548,11 @@ static int config_list(uint32_t key, GVariant **data,
                }
                *data = g_variant_builder_end(&gvb);
                return SR_OK;
+       case SR_CONF_RANGE:
+               if (!devc || !devc->model->get_range_text_list)
+                       return SR_ERR_NA;
+               *data = devc->model->get_range_text_list(sdi);
+               return SR_OK;
        default:
                (void)devc;
                return SR_ERR_NA;
@@ -391,6 +567,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        const struct mqopt_item *item;
        const char *command;
        char *response;
+       gboolean do_mq_meas_delay;
 
        scpi = sdi->conn;
        devc = sdi->priv;
@@ -409,14 +586,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                ret = sr_scpi_get_string(scpi, command, &response);
                if (ret == SR_OK) {
                        g_strstrip(response);
-                       if (devc->precision)
-                               g_free(devc->precision);
-                       devc->precision=g_strdup(response);
+                       g_free(devc->precision);
+                       devc->precision = g_strdup(response);
                        g_free(response);
                        sr_dbg("%s: Precision: '%s'", __func__, devc->precision);
                } else {
-                       sr_info("%s: Precision query ('%s') failed: %d",
-                               __func__, command, ret);
+                       sr_info("Precision query ('%s') failed: %d",
+                               command, ret);
                }
        }
 
@@ -428,6 +604,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                        return ret;
        }
 
+       do_mq_meas_delay = item->drv_flags & FLAG_MEAS_DELAY;
+       if (do_mq_meas_delay && devc->model->meas_delay_us)
+               g_usleep(devc->model->meas_delay_us);
+
        sr_sw_limits_acquisition_start(&devc->limits);
        ret = std_session_send_df_header(sdi);
        if (ret != SR_OK)
@@ -459,10 +639,8 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        std_session_send_df_end(sdi);
 
-       if (devc->precision) {
-               g_free(devc->precision);
-               devc->precision = NULL;
-       }
+       g_free(devc->precision);
+       devc->precision = NULL;
 
        return SR_OK;
 }