]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/lecroy-xstream/api.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / lecroy-xstream / api.c
index 8d4fe0b291eb775189535e9f8124083146d295cd..8551351a11a2994270879e9b461b566e08881e70 100644 (file)
@@ -204,7 +204,6 @@ static int config_set(uint32_t key, GVariant *data,
        const struct scope_config *model;
        struct scope_state *state;
        double tmp_d;
-       gboolean update_sample_rate;
 
        if (!sdi)
                return SR_ERR_ARG;
@@ -213,9 +212,6 @@ static int config_set(uint32_t key, GVariant *data,
 
        model = devc->model_config;
        state = devc->model_state;
-       update_sample_rate = FALSE;
-
-       ret = SR_ERR_NA;
 
        switch (key) {
        case SR_CONF_LIMIT_FRAMES:
@@ -249,7 +245,6 @@ static int config_set(uint32_t key, GVariant *data,
                g_snprintf(command, sizeof(command),
                                "TIME_DIV %E", (float) (*model->timebases)[idx][0] / (*model->timebases)[idx][1]);
                ret = sr_scpi_send(sdi->conn, command);
-               update_sample_rate = TRUE;
                break;
        case SR_CONF_HORIZ_TRIGGERPOS:
                tmp_d = g_variant_get_double(data);
@@ -296,9 +291,6 @@ static int config_set(uint32_t key, GVariant *data,
        if (ret == SR_OK)
                ret = sr_scpi_get_opc(sdi->conn);
 
-       if (ret == SR_OK && update_sample_rate)
-               ret = lecroy_xstream_update_sample_rate(sdi);
-
        return ret;
 }
 
@@ -323,13 +315,15 @@ static int config_list(uint32_t key, GVariant **data,
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
-               return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NULL, NULL);
+               return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NO_OPTS, NO_OPTS);
        case SR_CONF_DEVICE_OPTIONS:
                if (!cg)
-                       return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
+                       return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
                *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
                break;
        case SR_CONF_COUPLING:
+               if (!model)
+                       return SR_ERR_ARG;
                *data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options);
                break;
        case SR_CONF_TRIGGER_SOURCE:
@@ -366,6 +360,14 @@ SR_PRIV int lecroy_xstream_request_data(const struct sr_dev_inst *sdi)
        struct dev_context *devc;
 
        devc = sdi->priv;
+
+       /*
+        * We may be left with an invalid current_channel if acquisition was
+        * already stopped but we are processing the last pending events.
+        */
+       if (!devc->current_channel)
+               return SR_ERR_NA;
+
        ch = devc->current_channel->data;
 
        if (ch->type != SR_CHANNEL_ANALOG)
@@ -378,7 +380,6 @@ SR_PRIV int lecroy_xstream_request_data(const struct sr_dev_inst *sdi)
 static int setup_channels(const struct sr_dev_inst *sdi)
 {
        GSList *l;
-       gboolean setup_changed;
        char command[MAX_COMMAND_SIZE];
        struct scope_state *state;
        struct sr_channel *ch;
@@ -388,7 +389,6 @@ static int setup_channels(const struct sr_dev_inst *sdi)
        devc = sdi->priv;
        scpi = sdi->conn;
        state = devc->model_state;
-       setup_changed = FALSE;
 
        for (l = sdi->channels; l; l = l->next) {
                ch = l->data;
@@ -403,16 +403,12 @@ static int setup_channels(const struct sr_dev_inst *sdi)
                                return SR_ERR;
 
                        state->analog_channels[ch->index].state = ch->enabled;
-                       setup_changed = TRUE;
                        break;
                default:
                        return SR_ERR;
                }
        }
 
-       if (setup_changed && lecroy_xstream_update_sample_rate(sdi) != SR_OK)
-               return SR_ERR;
-
        return SR_OK;
 }
 
@@ -421,6 +417,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        GSList *l;
        struct sr_channel *ch;
        struct dev_context *devc;
+       struct scope_state *state;
        int ret;
        struct sr_scpi_dev_inst *scpi;
 
@@ -430,28 +427,22 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        /* Preset empty results. */
        g_slist_free(devc->enabled_channels);
        devc->enabled_channels = NULL;
+       state = devc->model_state;
+       state->sample_rate = 0;
 
-       /*
-        * Contruct the list of enabled channels. Determine the highest
-        * number of digital pods involved in the acquisition.
-        */
-
+       /* Contruct the list of enabled channels. */
        for (l = sdi->channels; l; l = l->next) {
                ch = l->data;
                if (!ch->enabled)
                        continue;
-               /* Only add a single digital channel per group (pod). */
-               devc->enabled_channels = g_slist_append(
-                       devc->enabled_channels, ch);
+
+               devc->enabled_channels = g_slist_append(devc->enabled_channels, ch);
        }
 
        if (!devc->enabled_channels)
                return SR_ERR;
 
-       /*
-        * Configure the analog channels and the
-        * corresponding digital pods.
-        */
+       /* Configure the analog channels. */
        if (setup_channels(sdi) != SR_OK) {
                sr_err("Failed to setup channel configuration!");
                ret = SR_ERR;