]> sigrok.org Git - libsigrok.git/blobdiff - hardware/rigol-ds/api.c
asix-sigma: Exterminate passing lastts and lastsample
[libsigrok.git] / hardware / rigol-ds / api.c
index ce78840b959c8ec03707e12e2c8684f0ad9cbbab..492b05ff21785dafb3dc2f2753d19025009b643e 100644 (file)
@@ -143,6 +143,11 @@ static const char *trigger_sources[] = {
        "D15",
 };
 
+static const char *trigger_slopes[] = {
+       "r",
+       "f",
+};
+
 static const char *coupling[] = {
        "AC",
        "DC",
@@ -268,8 +273,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
 
        if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
                sr_info("Couldn't get IDN response.");
-               sr_scpi_close(scpi);
-               sr_scpi_free(scpi);
                return NULL;
        }
 
@@ -287,13 +290,9 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                                                  model->name,
                                                  hw_info->firmware_version))) {
                sr_scpi_hw_info_free(hw_info);
-               sr_scpi_close(scpi);
-               sr_scpi_free(scpi);
                return NULL;
        }
 
-       sr_scpi_close(scpi);
-
        sdi->conn = scpi;
 
        sdi->driver = di;
@@ -335,7 +334,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        for (i = 0; i < model->analog_channels; i++) {
                if (!(channel_name = g_strdup_printf("CH%d", i + 1)))
                        return NULL;
-               ch = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel_name);
+               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel_name);
                sdi->channels = g_slist_append(sdi->channels, ch);
                devc->analog_groups[i].name = channel_name;
                devc->analog_groups[i].channels = g_slist_append(NULL, ch);
@@ -347,7 +346,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                for (i = 0; i < 16; i++) {
                        if (!(channel_name = g_strdup_printf("D%d", i)))
                                return NULL;
-                       ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, channel_name);
+                       ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
                        g_free(channel_name);
                        if (!ch)
                                return NULL;
@@ -445,7 +444,7 @@ static int analog_frame_size(const struct sr_dev_inst *sdi)
 
        for (l = sdi->channels; l; l = l->next) {
                ch = l->data;
-               if (ch->type == SR_PROBE_ANALOG && ch->enabled)
+               if (ch->type == SR_CHANNEL_ANALOG && ch->enabled)
                        analog_channels++;
        }
 
@@ -501,7 +500,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
                ch = g_slist_nth_data(cg->channels, 0);
                if (!ch)
                        return SR_ERR;
-               if (ch->type == SR_PROBE_ANALOG) {
+               if (ch->type == SR_CHANNEL_ANALOG) {
                        if (ch->name[2] < '1' || ch->name[2] > '4')
                                return SR_ERR;
                        analog_channel = ch->name[2] - '1';
@@ -546,6 +545,15 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
                        tmp_str = devc->trigger_source;
                *data = g_variant_new_string(tmp_str);
                break;
+       case SR_CONF_TRIGGER_SLOPE:
+               if (!strcmp(devc->trigger_slope, "POS"))
+                       tmp_str = "r";
+               else if (!strcmp(devc->trigger_slope, "NEG"))
+                       tmp_str = "f";
+               else
+                       return SR_ERR_NA;
+               *data = g_variant_new_string(tmp_str);
+               break;
        case SR_CONF_TIMEBASE:
                for (i = 0; i < devc->num_timebases; i++) {
                        float tb = (float)devc->timebases[i][0] / devc->timebases[i][1];
@@ -838,6 +846,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
                *data = g_variant_new_strv(trigger_sources,
                                devc->model->has_digital ? ARRAY_SIZE(trigger_sources) : 4);
                break;
+       case SR_CONF_TRIGGER_SLOPE:
+               *data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes));
+               break;
        case SR_CONF_DATA_SOURCE:
                if (!devc)
                        /* Can't know this until we have the exact model. */
@@ -880,7 +891,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        for (l = sdi->channels; l; l = l->next) {
                ch = l->data;
                sr_dbg("handling channel %s", ch->name);
-               if (ch->type == SR_PROBE_ANALOG) {
+               if (ch->type == SR_CHANNEL_ANALOG) {
                        if (ch->enabled)
                                devc->enabled_analog_channels = g_slist_append(
                                                devc->enabled_analog_channels, ch);
@@ -891,7 +902,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                                        return SR_ERR;
                                devc->analog_channels[ch->index] = ch->enabled;
                        }
-               } else if (ch->type == SR_PROBE_LOGIC) {
+               } else if (ch->type == SR_CHANNEL_LOGIC) {
                        if (ch->enabled) {
                                devc->enabled_digital_channels = g_slist_append(
                                                devc->enabled_digital_channels, ch);
@@ -931,7 +942,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
 
        switch (devc->model->series->protocol) {
        case PROTOCOL_V2:
-               if (rigol_ds_config_set(sdi, ":ACQ:MDEP LONG") != SR_OK)
+               if (rigol_ds_config_set(sdi, ":ACQ:MEMD LONG") != SR_OK)
                        return SR_ERR;
                break;
        case PROTOCOL_V3: