rigol-ds: add support for getting/setting trigger level.

This commit is contained in:
Aurelien Jacobs 2016-06-25 18:19:47 +02:00
parent 934cf6cf50
commit 9ea62f2e0a
5 changed files with 22 additions and 0 deletions

View File

@ -964,6 +964,9 @@ enum sr_configkey {
/** Under-voltage condition active. */
SR_CONF_UNDER_VOLTAGE_CONDITION_ACTIVE,
/** Trigger level. */
SR_CONF_TRIGGER_LEVEL,
/* Update sr_key_info_config[] (hwdriver.c) upon changes! */
/*--- Special stuff -------------------------------------------------*/

View File

@ -43,6 +43,7 @@ static const uint32_t devopts[] = {
SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_LEVEL | SR_CONF_GET | SR_CONF_SET,
SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_SET,
SR_CONF_NUM_HDIV | SR_CONF_GET,
SR_CONF_SAMPLERATE | SR_CONF_GET,
@ -588,6 +589,9 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
}
*data = g_variant_new_string(tmp_str);
break;
case SR_CONF_TRIGGER_LEVEL:
*data = g_variant_new_double(devc->trigger_level);
break;
case SR_CONF_TIMEBASE:
for (i = 0; i < devc->num_timebases; i++) {
float tb = (float)devc->timebases[i][0] / devc->timebases[i][1];
@ -697,6 +701,13 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
g_ascii_formatd(buffer, sizeof(buffer), "%.6f", t_dbl);
ret = rigol_ds_config_set(sdi, ":TIM:OFFS %s", buffer);
break;
case SR_CONF_TRIGGER_LEVEL:
t_dbl = g_variant_get_double(data);
g_ascii_formatd(buffer, sizeof(buffer), "%.3f", t_dbl);
ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:LEV %s", buffer);
if (ret == SR_OK)
devc->trigger_level = t_dbl;
break;
case SR_CONF_TIMEBASE:
g_variant_get(data, "(tt)", &p, &q);
for (i = 0; i < devc->num_timebases; i++) {

View File

@ -856,6 +856,11 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
return SR_ERR;
sr_dbg("Current trigger slope %s", devc->trigger_slope);
/* Trigger level. */
if (sr_scpi_get_float(sdi->conn, ":TRIG:EDGE:LEV?", &devc->trigger_level) != SR_OK)
return SR_ERR;
sr_dbg("Current trigger level %g", devc->trigger_level);
return SR_OK;
}

View File

@ -124,6 +124,7 @@ struct dev_context {
char *trigger_source;
float horiz_triggerpos;
char *trigger_slope;
float trigger_level;
char *coupling[MAX_ANALOG_CHANNELS];
/* Operational state */

View File

@ -175,6 +175,8 @@ static struct sr_key_info sr_key_info_config[] = {
"Under-voltage condition", NULL},
{SR_CONF_UNDER_VOLTAGE_CONDITION_ACTIVE, SR_T_BOOL, "uvc_active",
"Under-voltage condition active", NULL},
{SR_CONF_TRIGGER_LEVEL, SR_T_FLOAT, "triggerlevel",
"Trigger level", NULL},
/* Special stuff */
{SR_CONF_SESSIONFILE, SR_T_STRING, "sessionfile",