]> sigrok.org Git - libsigrok.git/commitdiff
scpi-dmm: Add new command DMM_CMD_SETUP_LOCAL.
authorTimo Kokkonen <redacted>
Wed, 19 Aug 2020 06:29:18 +0000 (23:29 -0700)
committerTimo Kokkonen <redacted>
Thu, 20 Aug 2020 19:48:00 +0000 (12:48 -0700)
Add new command DMM_CMD_SETUP_LOCAL for setting device back
to "local" mode. If device implmements this command, it is
sent when driver is closed and after device "scan".

Define DMM_CMD_SETUP_LOCAL for GWInstek meters, so they get
returned to local mode automatically after use.

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

index 69f6fa2aef33debbaabddc3ed6d9dc6954b0c876..18fd6045f6d369e1aeeba0f3a132cdf6d40a3c64 100644 (file)
@@ -82,6 +82,7 @@ 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", },
@@ -93,6 +94,7 @@ static const struct scpi_command cmdset_gwinstek[] = {
 
 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, "*CLS;SYST:REM", },
@@ -249,6 +251,7 @@ 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);
@@ -285,6 +288,16 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                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;
 }
 
@@ -310,8 +323,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;
@@ -320,6 +336,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);
 }
 
index 9a6b7012daa09b0bf4c6957542ca83176697e601..fe6138d4c1de3e3b63a023ffb86997565dc41aa4 100644 (file)
@@ -40,6 +40,7 @@ enum scpi_dmm_cmdcode {
        DMM_CMD_STOP_ACQ,
        DMM_CMD_QUERY_VALUE,
        DMM_CMD_QUERY_PREC,
+       DMM_CMD_SETUP_LOCAL,
 };
 
 struct mqopt_item {