scpi-dmm: Add new command DMM_CMD_SETUP_LOCAL.

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.
This commit is contained in:
Timo Kokkonen 2020-08-18 23:29:18 -07:00
parent 25879a34e9
commit 4c80a27284
2 changed files with 27 additions and 0 deletions

View File

@ -82,6 +82,7 @@ static const struct scpi_command cmdset_hp[] = {
static const struct scpi_command cmdset_gwinstek[] = { static const struct scpi_command cmdset_gwinstek[] = {
{ DMM_CMD_SETUP_REMOTE, "SYST:REM", }, { DMM_CMD_SETUP_REMOTE, "SYST:REM", },
{ DMM_CMD_SETUP_LOCAL, "SYST:LOC", },
{ DMM_CMD_SETUP_FUNC, "CONF:%s", }, { DMM_CMD_SETUP_FUNC, "CONF:%s", },
{ DMM_CMD_QUERY_FUNC, "CONF:STAT:FUNC?", }, { DMM_CMD_QUERY_FUNC, "CONF:STAT:FUNC?", },
{ DMM_CMD_START_ACQ, "*CLS;SYST:REM", }, { 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[] = { static const struct scpi_command cmdset_gwinstek_906x[] = {
{ DMM_CMD_SETUP_REMOTE, "SYST:REM", }, { DMM_CMD_SETUP_REMOTE, "SYST:REM", },
{ DMM_CMD_SETUP_LOCAL, "SYST:LOC", },
{ DMM_CMD_SETUP_FUNC, "CONF:%s", }, { DMM_CMD_SETUP_FUNC, "CONF:%s", },
{ DMM_CMD_QUERY_FUNC, "CONF?", }, { DMM_CMD_QUERY_FUNC, "CONF?", },
{ DMM_CMD_START_ACQ, "*CLS;SYST:REM", }, { 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; struct dev_context *devc;
size_t i; size_t i;
gchar *channel_name; gchar *channel_name;
const char *command;
scpi_dmm_cmd_delay(scpi); scpi_dmm_cmd_delay(scpi);
ret = sr_scpi_get_hw_id(scpi, &hw_info); 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); 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; return sdi;
} }
@ -310,8 +323,11 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi; struct sr_scpi_dev_inst *scpi;
const char *command;
devc = sdi->priv;
scpi = sdi->conn; scpi = sdi->conn;
if (!scpi) if (!scpi)
return SR_ERR_BUG; return SR_ERR_BUG;
@ -320,6 +336,16 @@ static int dev_close(struct sr_dev_inst *sdi)
if (sdi->status <= SR_ST_INACTIVE) if (sdi->status <= SR_ST_INACTIVE)
return SR_OK; 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); return sr_scpi_close(scpi);
} }

View File

@ -40,6 +40,7 @@ enum scpi_dmm_cmdcode {
DMM_CMD_STOP_ACQ, DMM_CMD_STOP_ACQ,
DMM_CMD_QUERY_VALUE, DMM_CMD_QUERY_VALUE,
DMM_CMD_QUERY_PREC, DMM_CMD_QUERY_PREC,
DMM_CMD_SETUP_LOCAL,
}; };
struct mqopt_item { struct mqopt_item {