From 0d8074c6b9f45720b5ddb9f99f19c463aac9e2fb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 20 Dec 2022 16:26:04 +0100 Subject: [PATCH 1/6] clippy fixes --- src/time.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/time.rs b/src/time.rs index ee9405b..4d481fc 100644 --- a/src/time.rs +++ b/src/time.rs @@ -535,9 +535,8 @@ pub mod cds { unix_seconds: 0, submillis_precision: None, }; - let unix_days_seconds = - ccsds_to_unix_days(ccsds_days.into()) as i64 * SECONDS_PER_DAY as i64; - provider.setup(unix_days_seconds as i64, ms_of_day.into()); + let unix_days_seconds = ccsds_to_unix_days(ccsds_days.into()) * SECONDS_PER_DAY as i64; + provider.setup(unix_days_seconds, ms_of_day.into()); Ok(provider) } @@ -755,7 +754,7 @@ pub mod cds { } fn date_time(&self) -> Option> { - self.calc_date_time((self.ms_of_day % 1000) as u32) + self.calc_date_time(self.ms_of_day % 1000) } } From 884de647adcb06e771a41c7ebe2c4d997fed6363 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 20 Dec 2022 16:27:23 +0100 Subject: [PATCH 2/6] add PR link --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c229055..12d7c44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). The function now returns the remaining slice as well. - All CDS specific functionality was moved into the `cds` submodule of the `time` module. `CdsShortTimeProvider` was renamed to `TimeProvider`. + PR: https://egit.irs.uni-stuttgart.de/rust/spacepackets/pulls/3 ## Added From 51963d0f725cb41952e95acc7393f1fb714bb002 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 21 Dec 2022 10:14:13 +0100 Subject: [PATCH 3/6] remove default impl for cds TimeProvider --- src/time.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/time.rs b/src/time.rs index 4d481fc..5223b4d 100644 --- a/src/time.rs +++ b/src/time.rs @@ -317,7 +317,7 @@ pub mod cds { /// assert_eq!(stamp_deserialized.len_as_bytes(), 7); /// } /// ``` - #[derive(Debug, Copy, Clone, Default, PartialEq, Eq)] + #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct TimeProvider { pfield: u8, From b07cec28eafecdd068dc9b9c575b5b7ef351d7c4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 21 Dec 2022 10:14:58 +0100 Subject: [PATCH 4/6] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12d7c44..19c5bd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Fixed + +- Remove `Default` derive on CDS time provider. This can lead to uninitialized preamble fields. + ## Changed - `serde` support is now optional and behind the `serde` feature. From 275869960166249889bd20cfe37f273f203c105a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 21 Dec 2022 22:09:45 +0100 Subject: [PATCH 5/6] added sp header getter function --- src/tc.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tc.rs b/src/tc.rs index 9db2e86..268e5eb 100644 --- a/src/tc.rs +++ b/src/tc.rs @@ -279,6 +279,10 @@ impl<'slice> PusTc<'slice> { ) } + pub fn sp_header(&self) -> &SpHeader { + &self.sp_header + } + pub fn len_packed(&self) -> usize { let mut length = PUS_TC_MIN_LEN_WITHOUT_APP_DATA; if let Some(app_data) = self.app_data { From 5df221759fb88f4aff3f4b38f2ed5942e2d88012 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 22 Dec 2022 23:55:05 +0100 Subject: [PATCH 6/6] conversion from now bugfix --- src/time.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/time.rs b/src/time.rs index 5223b4d..d62ffe7 100644 --- a/src/time.rs +++ b/src/time.rs @@ -362,8 +362,8 @@ pub mod cds { )); } SubmillisPrecision::Picoseconds(_) => { - prec = Some(SubmillisPrecision::Microseconds( - (now.subsec_nanos() * 1000) as u16, + prec = Some(SubmillisPrecision::Picoseconds( + (now.subsec_nanos() * 1000) as u32, )); } _ => (),