X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Frigol-ds%2Fapi.c;h=99d718313fc50dd24dbed2f876872847fe469778;hb=c2b394d56220de371280ff6e2b83559e1b1d27b6;hp=ec67d22d9372c1b3f33bb8310d2cd146089eb189;hpb=5415e6024766fb9cd130782415eabcfe243bb3aa;p=libsigrok.git diff --git a/hardware/rigol-ds/api.c b/hardware/rigol-ds/api.c index ec67d22d..99d71831 100644 --- a/hardware/rigol-ds/api.c +++ b/hardware/rigol-ds/api.c @@ -41,6 +41,7 @@ static const int32_t hwcaps[] = { SR_CONF_HORIZ_TRIGGERPOS, SR_CONF_NUM_TIMEBASE, SR_CONF_LIMIT_FRAMES, + SR_CONF_SAMPLERATE, }; static const int32_t analog_hwcaps[] = { @@ -492,13 +493,13 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_probe_group *probe_group) { struct dev_context *devc; + uint64_t samplerate; if (!sdi || !(devc = sdi->priv)) return SR_ERR_ARG; /* If a probe group is specified, it must be a valid one. */ - if (probe_group && !g_slist_find(sdi->probe_groups, probe_group)) - { + if (probe_group && !g_slist_find(sdi->probe_groups, probe_group)) { sr_err("Invalid probe group specified."); return SR_ERR; } @@ -517,6 +518,15 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, else *data = g_variant_new_string("Segmented"); break; + case SR_CONF_SAMPLERATE: + if (devc->data_source == DATA_SOURCE_LIVE) { + samplerate = analog_frame_size(sdi) / + (devc->timebase * devc->model->num_horizontal_divs); + *data = g_variant_new_uint64(samplerate); + } else { + return SR_ERR_NA; + } + break; default: return SR_ERR_NA; } @@ -541,8 +551,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, return SR_ERR_DEV_CLOSED; /* If a probe group is specified, it must be a valid one. */ - if (probe_group && !g_slist_find(sdi->probe_groups, probe_group)) - { + if (probe_group && !g_slist_find(sdi->probe_groups, probe_group)) { sr_err("Invalid probe group specified."); return SR_ERR; } @@ -797,6 +806,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) scpi = sdi->conn; devc = sdi->priv; + devc->num_frames = 0; + for (l = sdi->probes; l; l = l->next) { probe = l->data; sr_dbg("handling probe %s", probe->name); @@ -811,9 +822,16 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } } else if (probe->type == SR_PROBE_LOGIC) { - if (probe->enabled) + if (probe->enabled) { devc->enabled_digital_probes = g_slist_append( devc->enabled_digital_probes, probe); + /* Turn on LA module if currently off. */ + if (!devc->la_enabled) { + if (set_cfg(sdi, ":LA:DISP ON") != SR_OK) + return SR_ERR; + devc->la_enabled = TRUE; + } + } if (probe->enabled != devc->digital_channels[probe->index]) { /* Enabled channel is currently disabled, or vice versa. */ if (set_cfg(sdi, ":DIG%d:TURN %s", probe->index, @@ -826,6 +844,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (!devc->enabled_analog_probes && !devc->enabled_digital_probes) return SR_ERR; + /* Turn off LA module if on and no digital probes selected. */ + if (devc->la_enabled && !devc->enabled_digital_probes) + if (set_cfg(sdi, ":LA:DISP OFF") != SR_OK) + return SR_ERR; + if (devc->data_source == DATA_SOURCE_LIVE) { if (set_cfg(sdi, ":RUN") != SR_OK) return SR_ERR; @@ -857,8 +880,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } else { if (devc->enabled_analog_probes) { - if (devc->data_source == DATA_SOURCE_MEMORY) - { + if (devc->data_source == DATA_SOURCE_MEMORY) { /* Apparently for the DS2000 the memory * depth can only be set in Running state - * this matches the behaviour of the UI. */ @@ -881,6 +903,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_scpi_dev_inst *scpi; + struct sr_datafeed_packet packet; (void)cb_data; @@ -891,6 +914,10 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } + /* End of last frame. */ + packet.type = SR_DF_END; + sr_session_send(sdi, &packet); + g_slist_free(devc->enabled_analog_probes); g_slist_free(devc->enabled_digital_probes); devc->enabled_analog_probes = NULL;