projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Properly handle decoder errors
[pulseview.git]
/
pv
/
data
/
decodesignal.cpp
diff --git
a/pv/data/decodesignal.cpp
b/pv/data/decodesignal.cpp
index fbbdd793952d4ffd578532944ae4cab9c66ecfe5..65436002c760681a8b1b8117f15c74932479f4a2 100644
(file)
--- a/
pv/data/decodesignal.cpp
+++ b/
pv/data/decodesignal.cpp
@@
-279,19
+279,33
@@
void DecodeSignal::auto_assign_signals(const shared_ptr<Decoder> dec)
if (ch.assigned_signal)
continue;
if (ch.assigned_signal)
continue;
+ const QString ch_name = ch.name.toLower();
+
+ shared_ptr<data::SignalBase> match;
for (shared_ptr<data::SignalBase> s : session_.signalbases()) {
if (!s->enabled())
continue;
for (shared_ptr<data::SignalBase> s : session_.signalbases()) {
if (!s->enabled())
continue;
- const QString ch_name = ch.name.toLower();
const QString s_name = s->name().toLower();
if (s->logic_data() &&
((ch_name.contains(s_name)) || (s_name.contains(ch_name)))) {
const QString s_name = s->name().toLower();
if (s->logic_data() &&
((ch_name.contains(s_name)) || (s_name.contains(ch_name)))) {
- ch.assigned_signal = s.get();
- new_assignment = true;
+ if (!match)
+ match = s;
+ else {
+ // Only replace an existing match if it matches more characters
+ int old_unmatched = ch_name.length() - match->name().length();
+ int new_unmatched = ch_name.length() - s->name().length();
+ if (abs(new_unmatched) < abs(old_unmatched))
+ match = s;
+ }
}
}
}
}
+
+ if (match) {
+ ch.assigned_signal = match.get();
+ new_assignment = true;
+ }
}
if (new_assignment) {
}
if (new_assignment) {
@@
-384,7
+398,8
@@
int64_t DecodeSignal::get_working_sample_count(uint32_t segment_id) const
return (no_signals_assigned ? 0 : count);
}
return (no_signals_assigned ? 0 : count);
}
-int64_t DecodeSignal::get_decoded_sample_count(uint32_t segment_id) const
+int64_t DecodeSignal::get_decoded_sample_count(uint32_t segment_id,
+ bool include_processing) const
{
lock_guard<mutex> decode_lock(output_mutex_);
{
lock_guard<mutex> decode_lock(output_mutex_);
@@
-392,7
+407,10
@@
int64_t DecodeSignal::get_decoded_sample_count(uint32_t segment_id) const
try {
const DecodeSegment *segment = &(segments_.at(segment_id));
try {
const DecodeSegment *segment = &(segments_.at(segment_id));
- result = segment->samples_decoded;
+ if (include_processing)
+ result = segment->samples_decoded_incl;
+ else
+ result = segment->samples_decoded_excl;
} catch (out_of_range&) {
// Do nothing
}
} catch (out_of_range&) {
// Do nothing
}
@@
-888,6
+906,7
@@
void DecodeSignal::logic_mux_proc()
logic_mux_cond_.wait(logic_mux_lock);
}
}
logic_mux_cond_.wait(logic_mux_lock);
}
}
+
} while (!logic_mux_interrupt_);
}
} while (!logic_mux_interrupt_);
}
@@
-899,17
+918,17
@@
void DecodeSignal::decode_data(
const int64_t chunk_sample_count = DecodeChunkLength / unit_size;
for (int64_t i = abs_start_samplenum;
const int64_t chunk_sample_count = DecodeChunkLength / unit_size;
for (int64_t i = abs_start_samplenum;
- !decode_interrupt_ && (i < (abs_start_samplenum + sample_count));
+ error_message_.isEmpty() && !decode_interrupt_ &&
+ (i < (abs_start_samplenum + sample_count));
i += chunk_sample_count) {
const int64_t chunk_end = min(i + chunk_sample_count,
abs_start_samplenum + sample_count);
i += chunk_sample_count) {
const int64_t chunk_end = min(i + chunk_sample_count,
abs_start_samplenum + sample_count);
- // Report this chunk as already decoded so that annotations don't
- // appear in an area that we claim to not having been been decoded yet
{
lock_guard<mutex> lock(output_mutex_);
{
lock_guard<mutex> lock(output_mutex_);
- segments_.at(current_segment_id_).samples_decoded = chunk_end;
+ // Update the sample count showing the samples including currently processed ones
+ segments_.at(current_segment_id_).samples_decoded_incl = chunk_end;
}
int64_t data_size = (chunk_end - i) * unit_size;
}
int64_t data_size = (chunk_end - i) * unit_size;
@@
-917,14
+936,17
@@
void DecodeSignal::decode_data(
input_segment->get_samples(i, chunk_end, chunk);
if (srd_session_send(srd_session_, i, chunk_end, chunk,
input_segment->get_samples(i, chunk_end, chunk);
if (srd_session_send(srd_session_, i, chunk_end, chunk,
- data_size, unit_size) != SRD_OK)
{
+ data_size, unit_size) != SRD_OK)
set_error_message(tr("Decoder reported an error"));
set_error_message(tr("Decoder reported an error"));
- delete[] chunk;
- break;
- }
delete[] chunk;
delete[] chunk;
+ {
+ lock_guard<mutex> lock(output_mutex_);
+ // Now that all samples are processed, the exclusive sample count catches up
+ segments_.at(current_segment_id_).samples_decoded_excl = chunk_end;
+ }
+
// Notify the frontend that we processed some data and
// possibly have new annotations as well
new_annotations();
// Notify the frontend that we processed some data and
// possibly have new annotations as well
new_annotations();