From 1dcd92cff04417b71df5db4b1b3482e675d40051 Mon Sep 17 00:00:00 2001 From: DreamSourceLab Date: Thu, 8 Oct 2015 18:16:44 +0800 Subject: [PATCH] Fix session load issues --- DSView/CMakeLists.txt | 2 ++ DSView/pv/data/decode/decoder.cpp | 1 + DSView/pv/data/dsosnapshot.cpp | 2 +- DSView/pv/data/groupsnapshot.cpp | 53 +--------------------------- DSView/pv/data/logicsnapshot.cpp | 1 + DSView/pv/dialogs/deviceoptions.cpp | 21 +++++------ DSView/pv/dialogs/dsomeasure.cpp | 1 + DSView/pv/sigsession.cpp | 1 + DSView/pv/sigsession.h | 2 -- DSView/pv/toolbars/samplingbar.cpp | 28 +++++++++++---- DSView/pv/view/dsosignal.cpp | 14 ++++++-- DSView/pv/view/viewport.cpp | 2 +- libsigrok4DSL/hardware/DSL/dscope.c | 6 +++- libsigrok4DSL/hardware/DSL/dslogic.c | 38 +++++++++++--------- 14 files changed, 80 insertions(+), 92 deletions(-) diff --git a/DSView/CMakeLists.txt b/DSView/CMakeLists.txt index 652cb58..d26d1c5 100644 --- a/DSView/CMakeLists.txt +++ b/DSView/CMakeLists.txt @@ -144,6 +144,7 @@ set(DSView_SOURCES pv/dialogs/storeprogress.cpp pv/dialogs/streamoptions.cpp pv/dialogs/waitingdialog.cpp + pv/dialogs/dsomeasure.cpp pv/dock/dsotriggerdock.cpp pv/dock/measuredock.cpp pv/dock/searchdock.cpp @@ -189,6 +190,7 @@ set(DSView_HEADERS pv/dialogs/storeprogress.h pv/dialogs/streamoptions.h pv/dialogs/waitingdialog.h + pv/dialogs/dsomeasure.h pv/dock/dsotriggerdock.h pv/dock/measuredock.h pv/dock/searchdock.h diff --git a/DSView/pv/data/decode/decoder.cpp b/DSView/pv/data/decode/decoder.cpp index 6e8bd2e..00d6a1f 100644 --- a/DSView/pv/data/decode/decoder.cpp +++ b/DSView/pv/data/decode/decoder.cpp @@ -134,6 +134,7 @@ set< shared_ptr > Decoder::get_data() srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_size) const { + (void)unit_size; GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/pv/data/dsosnapshot.cpp index 7585561..8cb95f6 100644 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/pv/data/dsosnapshot.cpp @@ -148,7 +148,7 @@ void DsoSnapshot::reallocate_envelope(Envelope &e) void DsoSnapshot::append_payload_to_envelope_levels() { - for (int i = 0; i < _channel_num; i++) { + for (unsigned int i = 0; i < _channel_num; i++) { Envelope &e0 = _envelope_levels[i][0]; uint64_t prev_length; EnvelopeSample *dest_ptr; diff --git a/DSView/pv/data/groupsnapshot.cpp b/DSView/pv/data/groupsnapshot.cpp index 51dd70d..69a18f1 100644 --- a/DSView/pv/data/groupsnapshot.cpp +++ b/DSView/pv/data/groupsnapshot.cpp @@ -126,8 +126,6 @@ const uint16_t* GroupSnapshot::get_samples( assert(start_sample <= end_sample); int64_t i; - uint64_t pow; - uint16_t mask; uint16_t tmpl, tmpr; boost::lock_guard lock(_mutex); @@ -192,7 +190,6 @@ void GroupSnapshot::append_payload_to_envelope_levels() Envelope &e0 = _envelope_levels[0]; uint64_t prev_length; EnvelopeSample *dest_ptr; - uint16_t mask; // Expand the data buffer to fit the new samples prev_length = e0.length; @@ -226,56 +223,8 @@ void GroupSnapshot::append_payload_to_envelope_levels() group_value[i] <<= _bubble_start[j]; group_value[i] += tmpr; } -// group_value[i] = 0; -// std::list::iterator j = _index_list.begin(); -// pow = 0; -// while(j != _index_list.end()) { -// mask = value_mask[(*j)]; -// if ( *(j+1) == (*j) + 1) -// mask |= value_mask[*(j+1)]; -// group_value[i] += ((*(src_ptr + i) & value_mask[(*j)]) >> ((*j) - pow)); -// pow++; -// j++; -// } } -// group_value[0] = 0; -// group_value[1] = 0; -// group_value[2] = 0; -// group_value[3] = 0; -// group_value[4] = 0; -// group_value[5] = 0; -// group_value[6] = 0; -// group_value[7] = 0; -// group_value[8] = 0; -// group_value[9] = 0; -// group_value[10] = 0; -// group_value[11] = 0; -// group_value[12] = 0; -// group_value[13] = 0; -// group_value[14] = 0; -// group_value[15] = 0; -// std::list::iterator j = _index_list.begin(); -// pow = 0; -// while(j != _index_list.end()) { -// group_value[0] += ((*(src_ptr + 0) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[1] += ((*(src_ptr + 1) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[2] += ((*(src_ptr + 2) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[3] += ((*(src_ptr + 3) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[4] += ((*(src_ptr + 4) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[5] += ((*(src_ptr + 5) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[6] += ((*(src_ptr + 6) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[7] += ((*(src_ptr + 7) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[8] += ((*(src_ptr + 8) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[9] += ((*(src_ptr + 9) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[10] += ((*(src_ptr + 10) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[11] += ((*(src_ptr + 11) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[12] += ((*(src_ptr + 12) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[13] += ((*(src_ptr + 13) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[14] += ((*(src_ptr + 14) & value_mask[(*j)]) >> ((*j) - pow)); -// group_value[15] += ((*(src_ptr + 15) & value_mask[(*j)]) >> ((*j) - pow)); -// pow++; -// j++; -// } + const EnvelopeSample sub_sample = { *min_element(group_value, group_value + EnvelopeScaleFactor), *max_element(group_value, group_value + EnvelopeScaleFactor), diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp index 2b53292..ebdb904 100644 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/pv/data/logicsnapshot.cpp @@ -83,6 +83,7 @@ uint8_t * LogicSnapshot::get_samples(int64_t start_sample, int64_t end_sample) c assert(end_sample <= (int64_t)_sample_count); assert(start_sample <= end_sample); + (void)end_sample; //lock_guard lock(_mutex); //const size_t size = (end_sample - start_sample) * _unit_size; diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index f8a1a88..29c5920 100644 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -139,7 +139,7 @@ void DeviceOptions::setup_probes() int row0 = 0, row1 = 0, col = 0; int index = 0; - uint16_t ch_mode; + QString ch_mode; while(_probes_box_layout.count() > 0) { @@ -159,16 +159,17 @@ void DeviceOptions::setup_probes() const char **const options = g_variant_get_strv(gvar_opts, &num_opts); GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_CHANNEL_MODE); if (gvar != NULL) { - ch_mode = g_variant_get_uint16(gvar); + ch_mode = g_variant_get_string(gvar, NULL); g_variant_unref(gvar); - } - for (int i=0; isetChecked(true); + + for (unsigned int i=0; isetChecked(true); + } } } g_variant_unref(gvar_opts); diff --git a/DSView/pv/dialogs/dsomeasure.cpp b/DSView/pv/dialogs/dsomeasure.cpp index 69b3084..9bb3690 100644 --- a/DSView/pv/dialogs/dsomeasure.cpp +++ b/DSView/pv/dialogs/dsomeasure.cpp @@ -61,6 +61,7 @@ DsoMeasure::DsoMeasure(QWidget *parent, boost::shared_ptr dsoSig) : void DsoMeasure::set_measure(bool en) { + (void)en; QCheckBox* sc=dynamic_cast(sender()); if(sc != NULL) { QVariant id = sc->property("id"); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 3550b4a..459b4fa 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -436,6 +436,7 @@ void SigSession::start_capture(bool instant, void SigSession::stop_capture() { + _instant = false; if (get_capture_state() != Running) return; sr_session_stop(); diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index b781b69..fbee995 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -122,8 +122,6 @@ public: void set_default_device(boost::function error_handler); void export_file(const QString name, QWidget* parent, const QString ext); - void set_default_device(); - void release_device(device::DevInst *dev_inst); capture_state get_capture_state() const; diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index 90d6d29..8b06e0c 100644 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -291,12 +291,24 @@ void SamplingBar::set_record_length(uint64_t length) void SamplingBar::update_record_length() { + disconnect(&_sample_count, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_samplecount_sel(int))); + update_sample_count_selector_value(); + + connect(&_sample_count, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_samplecount_sel(int))); } void SamplingBar::update_sample_rate() { + disconnect(&_sample_rate, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_samplerate_sel(int))); + update_sample_rate_selector_value(); + + connect(&_sample_rate, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_samplerate_sel(int))); } void SamplingBar::set_sampling(bool sampling) @@ -417,9 +429,9 @@ void SamplingBar::update_sample_rate_selector() _updating_sample_rate = false; g_variant_unref(gvar_dict); + update_sample_rate_selector_value(); connect(&_sample_rate, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplerate_sel(int))); - update_sample_rate_selector_value(); } void SamplingBar::update_sample_rate_selector_value() @@ -486,13 +498,14 @@ void SamplingBar::on_samplecount_sel(int index) //bool buffer2stream = false; //bool stream2buffer = false; + qDebug() << "index: " << index; if (index >= 0) sample_count = _sample_count.itemData( index).value(); boost::shared_ptr _devInst = get_selected_device(); assert(_devInst); - +qDebug() << "1!\n"; if (strcmp(_devInst->dev_inst()->driver->name, "DSLogic") == 0 && _devInst->dev_inst()->mode != DSO) { /*GVariant* gvar = _devInst->get_config(NULL, NULL, SR_CONF_LIMIT_SAMPLES); if (gvar != NULL) { @@ -518,23 +531,26 @@ void SamplingBar::on_samplecount_sel(int index) stream_mode = sample_count > max_sample_count; stream2buffer = true; }*/ - +qDebug() << "2!\n"; // Set the sample count _devInst->set_config(NULL, NULL, SR_CONF_LIMIT_SAMPLES, g_variant_new_uint64(sample_count)); - +qDebug() << "21!\n"; GVariant* gvar = _devInst->get_config(NULL, NULL, SR_CONF_STREAM); if (gvar != NULL) { stream_mode = g_variant_get_boolean(gvar); g_variant_unref(gvar); } + qDebug() << "22!\n"; gvar = _devInst->get_config(NULL, NULL, SR_CONF_MAX_LOGIC_SAMPLELIMITS); + qDebug() << "23!\n"; if (gvar != NULL) { max_sample_count = g_variant_get_uint64(gvar); g_variant_unref(gvar); } + qDebug() << "3!\n"; if (!stream_mode) { if (sample_count > max_sample_count) { _devInst->set_config(NULL, NULL, @@ -546,7 +562,7 @@ void SamplingBar::on_samplecount_sel(int index) g_variant_new_boolean(false)); } } - +qDebug() << "4!\n"; /*if (buffer2stream) { pv::dialogs::StreamOptions stream(this, _devInst, sample_count, stream_mode); stream.setFixedSize(300, 150); @@ -675,9 +691,9 @@ void SamplingBar::update_sample_count_selector() _updating_sample_count = false; g_variant_unref(gvar_dict); + update_sample_count_selector_value(); connect(&_sample_count, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplecount_sel(int))); - update_sample_count_selector_value(); } void SamplingBar::update_sample_count_selector_value() diff --git a/DSView/pv/view/dsosignal.cpp b/DSView/pv/view/dsosignal.cpp index cedc272..7c23161 100644 --- a/DSView/pv/view/dsosignal.cpp +++ b/DSView/pv/view/dsosignal.cpp @@ -428,6 +428,7 @@ bool DsoSignal::go_hDialNext(bool setted) bool DsoSignal::update_vDial() { uint64_t vdiv; + uint64_t vfactor; //uint64_t pre_vdiv = _vDial->get_value(); GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_VDIV); if (gvar != NULL) { @@ -437,10 +438,18 @@ bool DsoSignal::update_vDial() qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed."; return false; } + gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_FACTOR); + if (gvar != NULL) { + vfactor = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + } else { + qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed."; + return false; + } _vDial->set_value(vdiv); - _dev_inst->set_config(_probe, NULL, SR_CONF_VDIV, - g_variant_new_uint64(_vDial->get_value())); + _vDial->set_factor(vfactor); + if (_view) { update_zeroPos(); _view->set_need_update(true); @@ -599,6 +608,7 @@ void DsoSignal::set_zeroPos(int pos) void DsoSignal::set_zeroRate(double rate) { _zeroPos = rate; + _zero_off = rate * 255; update_zeroPos(); } diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index 9e03acc..43f0145 100644 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -32,7 +32,7 @@ #include "../data/logic.h" #include "../data/logicsnapshot.h" #include "../sigsession.h" -#include <../dialogs/dsomeasure.h> +#include "../dialogs/dsomeasure.h" #include #include diff --git a/libsigrok4DSL/hardware/DSL/dscope.c b/libsigrok4DSL/hardware/DSL/dscope.c index 77aca0b..8e1a9cf 100644 --- a/libsigrok4DSL/hardware/DSL/dscope.c +++ b/libsigrok4DSL/hardware/DSL/dscope.c @@ -48,8 +48,12 @@ static struct sr_dev_mode mode_list[] = { static const char *opmodes[] = { "Normal", "Internal Test", + "External Test", + "DRAM Loopback Test", }; +static uint16_t opmodes_show_count = 2; + static const char *thresholds[] = { "1.8/2.5/3.3V Level", "5.0V Level", @@ -1649,7 +1653,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, *data = g_variant_new_string(TRIGGER_TYPE); break; case SR_CONF_OPERATION_MODE: - *data = g_variant_new_strv(opmodes, ARRAY_SIZE(opmodes)); + *data = g_variant_new_strv(opmodes, opmodes_show_count); break; case SR_CONF_THRESHOLD: *data = g_variant_new_strv(thresholds, ARRAY_SIZE(thresholds)); diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index fced7cc..c3bd819 100644 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -55,8 +55,12 @@ static const char *opmodes[] = { "Buffer Mode", "Stream Mode", "Internal Test", + "External Test", + "DRAM Loopback Test", }; +static uint16_t opmodes_show_count = 3; + static const char *stream_ch_modes[] = { "Use Channels 0~15 (Max 10MHz)", "Use Channels 0~7 (Max 25MHz)", @@ -229,7 +233,6 @@ static const uint64_t samplecounts[] = { SR_MB(128), SR_MB(256), SR_MB(512), - SR_GB(1), }; static const uint8_t zero_base_addr = 0x80; @@ -1172,7 +1175,6 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, struct DSL_context *devc; struct sr_usb_dev_inst *usb; char str[128]; - uint64_t max_limits = DSLOGIC_MAX_LOGIC_DEPTH; (void)cg; @@ -1234,7 +1236,10 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, if (!sdi) return SR_ERR; devc = sdi->priv; - *data = g_variant_new_uint16(devc->ch_mode); + if (devc->stream) + *data = g_variant_new_string(stream_ch_modes[devc->ch_mode]); + else + *data = g_variant_new_string(buffer_ch_modes[devc->ch_mode]); break; case SR_CONF_TEST: if (!sdi) @@ -1371,16 +1376,18 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_MAX_LOGIC_SAMPLELIMITS: if (!sdi) return SR_ERR; - if (devc->cur_samplerate == 2*DSLOGIC_MAX_LOGIC_SAMPLERATE) { - max_limits = DSLOGIC_MAX_LOGIC_DEPTH * 2; - } else if (devc->cur_samplerate == 4*DSLOGIC_MAX_LOGIC_SAMPLERATE) { - max_limits = DSLOGIC_MAX_LOGIC_DEPTH * 4; - } - *data = g_variant_new_uint64(max_limits); + sr_spew("dslogic:before"); + devc = sdi->priv; + sr_spew("DSLOGIC_MAX_LOGIC_DEPTH: %d", DSLOGIC_MAX_LOGIC_DEPTH); + sr_spew("devc->cur_samplerate: %d", devc->cur_samplerate); + sr_spew("DSLOGIC_MAX_LOGIC_SAMPLERATE: %d", DSLOGIC_MAX_LOGIC_SAMPLERATE); + *data = g_variant_new_uint64(DSLOGIC_MAX_LOGIC_DEPTH*ceil(devc->cur_samplerate * 1.0 / DSLOGIC_MAX_LOGIC_SAMPLERATE)); + sr_spew("dslogic:after"); break; case SR_CONF_STATUS: if (!sdi) return SR_ERR; + devc = sdi->priv; *data = g_variant_new_boolean(devc->status != DSL_INIT); break; default: @@ -1589,6 +1596,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } else { ret = SR_ERR; } + if (devc->cur_samplerate > samplerates[devc->samplerates_size-1]) + devc->cur_samplerate = samplerates[devc->samplerates_size-1]; sr_dbg("%s: setting pattern to %d", __func__, devc->op_mode); } else if (id == SR_CONF_CHANNEL_MODE) { @@ -1611,6 +1620,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, break; } } + if (devc->cur_samplerate > samplerates[devc->samplerates_size-1]) + devc->cur_samplerate = samplerates[devc->samplerates_size-1]; sr_dbg("%s: setting channel mode to %d", __func__, devc->ch_mode); } else if (id == SR_CONF_THRESHOLD) { @@ -1897,7 +1908,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, *data = g_variant_new_string(TRIGGER_TYPE); break; case SR_CONF_OPERATION_MODE: - *data = g_variant_new_strv(opmodes, ARRAY_SIZE(opmodes)); + *data = g_variant_new_strv(opmodes, opmodes_show_count); break; case SR_CONF_CHANNEL_MODE: if (devc->stream) @@ -2356,13 +2367,6 @@ static int dev_transfer_start(const struct sr_dev_inst *sdi) else dso_buffer_size = devc->limit_samples * channel_en_cnt + 512; -// if (sdi->mode == DSO) { -// timeout = 500; -// num_transfers = buffer_cnt; -// } else { -// timeout = get_timeout(devc); -// num_transfers = get_number_of_transfers(devc); -// } num_transfers = 1; size = (sdi->mode == ANALOG) ? cons_buffer_size : ((sdi->mode == DSO) ? dso_buffer_size : get_buffer_size(devc)); -- 2.30.2