Skip to content

Commit

Permalink
Improve time conversion handling, warn on user event fmt errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Jul 13, 2024
1 parent 47b0482 commit 86780a9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
56 changes: 28 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bytes = "1"
human_bytes = "0.4"
simple_moving_average = "1.0"
auxon-sdk = { version = "1.3", features = ["modality"] }
trace-recorder-parser = "0.16.1"
trace-recorder-parser = "0.17.0"

[dev-dependencies]
tempfile = "3.10"
Expand Down
4 changes: 3 additions & 1 deletion src/recorder_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ pub trait NanosecondsExt {
/// Convert to nanosecond time base using the frequency if non-zero
fn convert_timestamp<T: Into<Timestamp>>(&self, ticks: T) -> Option<Nanoseconds> {
let t = ticks.into();
let ticks_ns = u128::from(t.get_raw()) * u128::from(Self::ONE_SECOND);
self.timer_frequency()
.map(|freq| Nanoseconds::from((t.get_raw() * Self::ONE_SECOND) / freq))
.map(|freq| Nanoseconds::from((ticks_ns / u128::from(freq)) as u64))
}
}

Expand Down Expand Up @@ -842,6 +843,7 @@ impl From<Option<ObjectClass>> for MaybeUnknownObjectClass {

fn arg_to_attr_val(arg: &Argument) -> AttrVal {
match arg {
Argument::Char(v) => AttrVal::String(v.to_string().into()),
Argument::I8(v) => AttrVal::Integer(i64::from(*v)),
Argument::U8(v) => AttrVal::Integer(i64::from(*v)),
Argument::I16(v) => AttrVal::Integer(i64::from(*v)),
Expand Down
8 changes: 5 additions & 3 deletions src/trc_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ pub async fn run<R: Read + Send>(
Err(e) => {
use trace_recorder_parser::streaming::Error as TrcError;
match e {
TrcError::ObjectLookup(_)
| TrcError::InvalidObjectHandle(_)
| TrcError::FormattedString(_) => {
TrcError::ObjectLookup(_) | TrcError::InvalidObjectHandle(_) => {
ctx_mngr.set_degraded(format!("Data error {e}"));
continue;
}
TrcError::FixedUserEventFmtStringLookup(_) | TrcError::FormattedString(_) => {
warn!("Encountered an invalid user event. {e}");
continue;
}
TrcError::TraceRestarted(psf_start_word_endianness) => {
warn!("Detected a restarted trace stream");
trd =
Expand Down

0 comments on commit 86780a9

Please sign in to comment.