]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: add support for getting/setting trigger level.
authorAurelien Jacobs <redacted>
Sat, 25 Jun 2016 16:19:47 +0000 (18:19 +0200)
committerAurelien Jacobs <redacted>
Sat, 25 Jun 2016 16:19:47 +0000 (18:19 +0200)
include/libsigrok/libsigrok.h
src/hardware/rigol-ds/api.c
src/hardware/rigol-ds/protocol.c
src/hardware/rigol-ds/protocol.h
src/hwdriver.c

index b533d87ddd9a4314f542b8372ee7b4e22e6b0ec4..511ab28c0f074ce25afb5fe121ed038dda9298e6 100644 (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 -------------------------------------------------*/
index d21cff7d34c511383f69cacd4149434fa94cc13e..698a692f5c21d5cdc93ae689d61294d94c61cbc9 100644 (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++) {
index 0a60957cf1eff338b3deeea18ee35e3ac8885e01..d9d8dc7ea1d79f51352d813146b58f9971840b95 100644 (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;
 }
 
index cdf43f8b2a9f883ca6b454ecd69714b3016aff91..e77797047eac5c160d21ff21e4d1e1b424f5b394 100644 (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 */
index 6758f6a96fc07c1f905d0708a00710b2481787b8..c23e761a143bafad6fa611b667ba4fbb9863ca37 100644 (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",