From bc0684b57af238dc2431715eeef4e921811bb072 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 20 Feb 2023 16:17:40 +0800 Subject: [PATCH] fix: Can't restore the disabled channel from dso data file --- DSView/pv/data/dsosnapshot.cpp | 9 ++++----- DSView/pv/data/dsosnapshot.h | 2 +- DSView/pv/sigsession.cpp | 3 ++- libsigrok4DSL/session_driver.c | 4 +--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/pv/data/dsosnapshot.cpp index 047bda26..dec4b3e3 100644 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/pv/data/dsosnapshot.cpp @@ -111,10 +111,9 @@ void DsoSnapshot::free_data() } void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count, - GSList *channels, bool instant) + GSList *channels, bool instant, bool isFile) { - assert(channels); - //dsv_info("first total_sample_count:%llu", total_sample_count); + assert(channels); bool channel_changed = false; uint16_t channel_num = 0; @@ -123,7 +122,7 @@ void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sampl sr_channel *const probe = (sr_channel*)l->data; if (probe->type == SR_CHANNEL_DSO) { - if (probe->enabled){ + if (probe->enabled || isFile){ channel_num++; if (!channel_changed){ channel_changed = !has_data(probe->index); @@ -150,7 +149,7 @@ void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sampl for (const GSList *l = channels; l; l = l->next) { sr_channel *const probe = (sr_channel*)l->data; - if (probe->type == SR_CHANNEL_DSO && probe->enabled) { + if (probe->type == SR_CHANNEL_DSO && (probe->enabled || isFile)) { uint8_t *chan_buffer = (uint8_t*)malloc(total_sample_count + 1); if (chan_buffer == NULL){ diff --git a/DSView/pv/data/dsosnapshot.h b/DSView/pv/data/dsosnapshot.h index 12200987..119b812f 100644 --- a/DSView/pv/data/dsosnapshot.h +++ b/DSView/pv/data/dsosnapshot.h @@ -86,7 +86,7 @@ public: void init(); void first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count, - GSList *channels, bool instant); + GSList *channels, bool instant, bool isFile); void append_payload(const sr_datafeed_dso &dso); const uint8_t* get_samples(int64_t start_sample, int64_t end_sample, uint16_t index); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 5f8a66fb..c071b097 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -985,7 +985,8 @@ namespace pv _capture_data->get_dso()->first_payload(o, _device_agent.get_sample_limit(), _device_agent.get_channels(), - _is_instant); + _is_instant, + _device_agent.is_file()); } else { diff --git a/libsigrok4DSL/session_driver.c b/libsigrok4DSL/session_driver.c index 350813d2..65559262 100644 --- a/libsigrok4DSL/session_driver.c +++ b/libsigrok4DSL/session_driver.c @@ -1777,11 +1777,9 @@ static int sr_load_virtual_device_session(struct sr_dev_inst *sdi) } else if (!strncmp(keys[j], "enable", 6)) { - if (mode != LOGIC) - continue; - probenum = strtoul(keys[j] + 6, NULL, 10); tmp_u64 = strtoull(val, NULL, 10); + if (probenum < g_slist_length(sdi->channels)) { probe = g_slist_nth(sdi->channels, probenum)->data;