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 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, "*CLS;SYST:REM", },
- { DMM_CMD_STOP_ACQ, "SYST:LOC", },
+ { DMM_CMD_START_ACQ, "INIT", },
+ { DMM_CMD_STOP_ACQ, "ABORT", },
{ DMM_CMD_QUERY_VALUE, "VAL1?", },
{ DMM_CMD_QUERY_PREC, "SENS:DET:RATE?", },
ALL_ZERO,
1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a),
scpi_dmm_get_meas_agilent,
ARRAY_AND_SIZE(devopts_generic),
- 0,
+ 0, 0,
},
{
"Agilent", "34410A",
1, 6, cmdset_hp, ARRAY_AND_SIZE(mqopts_agilent_34405a),
scpi_dmm_get_meas_agilent,
ARRAY_AND_SIZE(devopts_generic),
- 0,
- },
- {
- "Keysight", "34465A",
- 1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a),
- scpi_dmm_get_meas_agilent,
- ARRAY_AND_SIZE(devopts_generic),
- 0,
- },
- {
- "HP", "34401A",
- 1, 6, cmdset_hp, ARRAY_AND_SIZE(mqopts_agilent_34401a),
- scpi_dmm_get_meas_agilent,
- ARRAY_AND_SIZE(devopts_generic),
- /* 34401A: typ. 1020ms for AC readings (default is 1000ms). */
- 1000 * 1500,
+ 0, 0,
},
{
"GW", "GDM8251A",
1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a),
scpi_dmm_get_meas_gwinstek,
ARRAY_AND_SIZE(devopts_generic),
- 1000 * 2500,
+ 1000 * 2500, 0,
},
{
"GW", "GDM8255A",
1, 6, cmdset_gwinstek, ARRAY_AND_SIZE(mqopts_gwinstek_gdm8200a),
scpi_dmm_get_meas_gwinstek,
ARRAY_AND_SIZE(devopts_generic),
- 1000 * 2500,
+ 1000 * 2500, 0,
},
{
"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,
},
{
"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,
+ },
+ {
+ "HP", "34401A",
+ 1, 6, cmdset_hp, ARRAY_AND_SIZE(mqopts_agilent_34401a),
+ scpi_dmm_get_meas_agilent,
+ ARRAY_AND_SIZE(devopts_generic),
+ /* 34401A: typ. 1020ms for AC readings (default is 1000ms). */
+ 1000 * 1500, 0,
+ },
+ {
+ "Keysight", "34465A",
+ 1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_34405a),
+ scpi_dmm_get_meas_agilent,
+ ARRAY_AND_SIZE(devopts_generic),
+ 0, 0,
},
};
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;
struct dev_context *devc;
size_t i;
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);
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;
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;
}
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;
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);
}
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);
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);
}
}
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;
}