X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Frigol-ds%2Fapi.c;h=465001048ac5af4a93c87d6db478a35f86140467;hb=a4e435eb49c1fa30c31d5851b404001324cafe33;hp=ce78840b959c8ec03707e12e2c8684f0ad9cbbab;hpb=ba7dd8bbb8168cba432a844259a3e239aa5f36d7;p=libsigrok.git diff --git a/hardware/rigol-ds/api.c b/hardware/rigol-ds/api.c index ce78840b..46500104 100644 --- a/hardware/rigol-ds/api.c +++ b/hardware/rigol-ds/api.c @@ -143,6 +143,11 @@ static const char *trigger_sources[] = { "D15", }; +static const char *trigger_slopes[] = { + "r", + "f", +}; + static const char *coupling[] = { "AC", "DC", @@ -267,10 +272,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) gchar *channel_name, **version; if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { - sr_info("Couldn't get IDN response."); + sr_info("Couldn't get IDN response, retrying."); sr_scpi_close(scpi); - sr_scpi_free(scpi); - return NULL; + sr_scpi_open(scpi); + if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { + sr_info("Couldn't get IDN response."); + return NULL; + } } for (i = 0; i < ARRAY_SIZE(supported_models); i++) { @@ -287,13 +295,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 +339,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 +351,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 +449,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 +505,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 +550,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 +851,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 +896,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 +907,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 +947,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: