Loading floss/hcidoc/packets/Cargo.toml +3 −0 Original line number Diff line number Diff line Loading @@ -37,3 +37,6 @@ walkdir = "2.2" [lib] path = "lib.rs" crate-type = ["rlib"] [features] serde = [] floss/hcidoc/src/parser.rs +12 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ const SNOOP_Y0_TO_Y1970_US: i64 = 62_168_256_000_000_000; /// Snoop file packet format. #[derive(Debug, Clone)] #[allow(dead_code)] pub struct SnoopPacketPreamble { /// The original length of the captured packet as received via a network. pub original_length: u32, Loading Loading @@ -177,7 +178,15 @@ pub trait GeneralSnoopPacket { fn get_timestamp(&self) -> Option<NaiveDateTime> { let preamble = self.preamble(); let ts_i64 = i64::try_from(preamble.timestamp_us).unwrap_or(i64::MAX); DateTime::from_timestamp_micros(ts_i64 - SNOOP_Y0_TO_Y1970_US).map(|date| date.naive_utc()) // TODO: directly use Datetime::from_timestamp_micros() once chrono package is re-vendored // to v0.4.35. Below is the actual implementation of that function. let from_timestamp_micros = |micros: i64| -> Option<DateTime<_>> { let secs = micros.div_euclid(1_000_000); let nsecs = micros.rem_euclid(1_000_000) as u32 * 1000; DateTime::from_timestamp(secs, nsecs) }; from_timestamp_micros(ts_i64 - SNOOP_Y0_TO_Y1970_US).map(|date| date.naive_utc()) } } Loading Loading @@ -420,6 +429,7 @@ impl<'a> TryFrom<&'a dyn GeneralSnoopPacket> for PacketChild { /// A single processable packet of data. #[derive(Debug, Clone)] #[allow(dead_code)] pub struct Packet { /// Timestamp of this packet pub ts: NaiveDateTime, Loading Loading @@ -454,6 +464,7 @@ impl<'a> TryFrom<(usize, &'a dyn GeneralSnoopPacket)> for Packet { } } #[allow(dead_code)] pub enum AclContent { Control(Control), LeControl(LeControl), Loading system/gd/rust/topshim/src/btif.rs +1 −1 Original line number Diff line number Diff line Loading @@ -435,7 +435,7 @@ impl ToString for BtVendorProductInfo { match self.vendor_id_src { 1 => "bluetooth", 2 => "usb", default => "unknown", _ => "unknown", }, self.vendor_id, self.product_id, Loading system/gd/rust/topshim/src/syslog.rs +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ //! to tune log levels for syslog. use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::cast::{FromPrimitive, ToPrimitive}; use num_traits::cast::ToPrimitive; use std::ffi::CString; use std::os::raw::c_char; Loading Loading
floss/hcidoc/packets/Cargo.toml +3 −0 Original line number Diff line number Diff line Loading @@ -37,3 +37,6 @@ walkdir = "2.2" [lib] path = "lib.rs" crate-type = ["rlib"] [features] serde = []
floss/hcidoc/src/parser.rs +12 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ const SNOOP_Y0_TO_Y1970_US: i64 = 62_168_256_000_000_000; /// Snoop file packet format. #[derive(Debug, Clone)] #[allow(dead_code)] pub struct SnoopPacketPreamble { /// The original length of the captured packet as received via a network. pub original_length: u32, Loading Loading @@ -177,7 +178,15 @@ pub trait GeneralSnoopPacket { fn get_timestamp(&self) -> Option<NaiveDateTime> { let preamble = self.preamble(); let ts_i64 = i64::try_from(preamble.timestamp_us).unwrap_or(i64::MAX); DateTime::from_timestamp_micros(ts_i64 - SNOOP_Y0_TO_Y1970_US).map(|date| date.naive_utc()) // TODO: directly use Datetime::from_timestamp_micros() once chrono package is re-vendored // to v0.4.35. Below is the actual implementation of that function. let from_timestamp_micros = |micros: i64| -> Option<DateTime<_>> { let secs = micros.div_euclid(1_000_000); let nsecs = micros.rem_euclid(1_000_000) as u32 * 1000; DateTime::from_timestamp(secs, nsecs) }; from_timestamp_micros(ts_i64 - SNOOP_Y0_TO_Y1970_US).map(|date| date.naive_utc()) } } Loading Loading @@ -420,6 +429,7 @@ impl<'a> TryFrom<&'a dyn GeneralSnoopPacket> for PacketChild { /// A single processable packet of data. #[derive(Debug, Clone)] #[allow(dead_code)] pub struct Packet { /// Timestamp of this packet pub ts: NaiveDateTime, Loading Loading @@ -454,6 +464,7 @@ impl<'a> TryFrom<(usize, &'a dyn GeneralSnoopPacket)> for Packet { } } #[allow(dead_code)] pub enum AclContent { Control(Control), LeControl(LeControl), Loading
system/gd/rust/topshim/src/btif.rs +1 −1 Original line number Diff line number Diff line Loading @@ -435,7 +435,7 @@ impl ToString for BtVendorProductInfo { match self.vendor_id_src { 1 => "bluetooth", 2 => "usb", default => "unknown", _ => "unknown", }, self.vendor_id, self.product_id, Loading
system/gd/rust/topshim/src/syslog.rs +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ //! to tune log levels for syslog. use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::cast::{FromPrimitive, ToPrimitive}; use num_traits::cast::ToPrimitive; use std::ffi::CString; use std::os::raw::c_char; Loading