X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=b1ce14680bbec848f6ae92fd3ec4010094d8320c;hp=ca72e9b0d670fed6a14da47d4c7c2ce79946c078;hb=bf84211be02b096646cf28cf9dc7480029e4f439;hpb=7ea2a4ff0765fdad34b84e4b4631d6f3f5588714 diff --git a/pv/session.cpp b/pv/session.cpp index ca72e9b0..b1ce1468 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -352,8 +352,7 @@ void Session::select_device(shared_ptr device) else set_default_device(); } catch (const QString &e) { - main_bar_->session_error(tr("Failed to Select Device"), - tr("Failed to Select Device")); + main_bar_->session_error(tr("Failed to select device"), e); } } @@ -401,6 +400,7 @@ void Session::set_device(shared_ptr device) device_->open(); } catch (const QString &e) { device_.reset(); + main_bar_->session_error(tr("Failed to open device"), e); } if (device_) { @@ -426,7 +426,7 @@ void Session::set_default_device() // Try and find the demo device and select that by default const auto iter = find_if(devices.begin(), devices.end(), [] (const shared_ptr &d) { - return d->hardware_device()->driver()->name() == "demo"; }); + return d->hardware_device()->driver()->name() == "demo"; }); set_device((iter == devices.end()) ? devices.front() : *iter); } @@ -1080,10 +1080,21 @@ void Session::feed_in_trigger() } } - // If no frame began then this is a trigger for a new segment - const uint32_t segment_id = - (frame_began_) ? highest_segment_id_ : (highest_segment_id_ + 1); + uint32_t segment_id = 0; // Default segment when no frames are used + + // If a frame began, we'd ideally be able to use the highest segment ID for + // the trigger. However, as new segments are only created when logic or + // analog data comes in, this doesn't work if the trigger appears right + // after the beginning of the frame, before any sample data. + // For this reason, we use highest segment ID + 1 if no sample data came in + // yet and the highest segment ID otherwise. + if (frame_began_) { + segment_id = highest_segment_id_; + if (!cur_logic_segment_ && (cur_analog_segments_.size() == 0)) + segment_id++; + } + // TODO Create timestamp from segment start time + segment's current sample count util::Timestamp timestamp = sample_count / get_samplerate(); trigger_list_.emplace_back(segment_id, timestamp); trigger_event(segment_id, timestamp);