]> sigrok.org Git - libsigrok.git/commitdiff
cem-dt-885x: Support for SR_CONF_DATA_SOURCE
authorBert Vermeulen <redacted>
Wed, 19 Jun 2013 10:23:30 +0000 (12:23 +0200)
committerBert Vermeulen <redacted>
Wed, 19 Jun 2013 10:23:30 +0000 (12:23 +0200)
This device can do both live and memory-based acquisition.

hardware/cem-dt-885x/api.c
hardware/cem-dt-885x/protocol.h

index 3b3082844cc4dad70cd20248f0c49da19f82a7b3..ca6805012fa455b43700dafbe5c0d6a0c57a0b8f 100644 (file)
@@ -39,6 +39,7 @@ static const int32_t hwcaps[] = {
        SR_CONF_HOLD_MAX,
        SR_CONF_HOLD_MIN,
        SR_CONF_POWER_OFF,
+       SR_CONF_DATA_SOURCE,
 };
 
 static const char *weight_freq[] = {
@@ -58,6 +59,10 @@ static const uint64_t meas_ranges[][2] = {
        { 80, 130 },
 };
 
+static const char *data_sources[] = {
+       "Live",
+       "Memory",
+};
 SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info;
 static struct sr_dev_driver *di = &cem_dt_885x_driver_info;
 
@@ -112,6 +117,7 @@ static GSList *scan(GSList *options)
                        devc->cur_mqflags = 0;
                        devc->recording = -1;
                        devc->cur_meas_range = 0;
+                       devc->cur_data_source = DATA_SOURCE_LIVE;
 
                        if (!(sdi->conn = sr_serial_dev_inst_new(conn, SERIALCOMM)))
                                return NULL;
@@ -236,6 +242,12 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi)
        case SR_CONF_POWER_OFF:
                *data = g_variant_new_boolean(FALSE);
                break;
+       case SR_CONF_DATA_SOURCE:
+               if (devc->cur_data_source == DATA_SOURCE_LIVE)
+                       *data = g_variant_new_string("Live");
+               else
+                       *data = g_variant_new_string("Memory");
+               break;
        default:
                return SR_ERR_NA;
        }
@@ -313,6 +325,15 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi)
                if (g_variant_get_boolean(data))
                        ret = cem_dt_885x_power_off(sdi);
                break;
+       case SR_CONF_DATA_SOURCE:
+               tmp_str = g_variant_get_string(data, NULL);
+               if (!strcmp(tmp_str, "Live"))
+                       devc->cur_data_source = DATA_SOURCE_LIVE;
+               else if (!strcmp(tmp_str, "Memory"))
+                       devc->cur_data_source = DATA_SOURCE_MEMORY;
+               else
+                       return SR_ERR;
+               break;
        default:
                ret = SR_ERR_NA;
        }
@@ -355,6 +376,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
                }
                *data = g_variant_builder_end(&gvb);
                break;
+       case SR_CONF_DATA_SOURCE:
+               *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
+               break;
        default:
                return SR_ERR_NA;
        }
index 28a7cc6ae24eb7e705581d15d6e1e1c974c38dd3..fa9474d6b99e52f1b50de4f9e08e742b29aa9519 100644 (file)
@@ -75,12 +75,18 @@ enum {
        CMD_TOGGLE_POWER_OFF = 0x33,
 };
 
+enum {
+       DATA_SOURCE_LIVE,
+       DATA_SOURCE_MEMORY,
+};
+
 /** Private, per-device-instance driver context. */
 struct dev_context {
        /* Device state */
        uint64_t cur_mqflags;
        int recording;
        int cur_meas_range;
+       int cur_data_source;
 
        /* Acquisition settings */
        uint64_t limit_samples;