From 76245cb55fbad7403bc2620005b106efc85dd8e0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 16:47:34 +0100 Subject: [PATCH] new resultcode module --- satrs-core/src/lib.rs | 1 + satrs-core/src/resultcode.rs | 36 ++++++++++++++++++++++++++++++++++++ satrs-macros/src/lib.rs | 1 + 3 files changed, 38 insertions(+) create mode 100644 satrs-core/src/resultcode.rs diff --git a/satrs-core/src/lib.rs b/satrs-core/src/lib.rs index 4fda814..700ebff 100644 --- a/satrs-core/src/lib.rs +++ b/satrs-core/src/lib.rs @@ -29,5 +29,6 @@ pub mod params; #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub mod pool; pub mod pus; +pub mod resultcode; pub mod seq_count; pub mod tmtc; diff --git a/satrs-core/src/resultcode.rs b/satrs-core/src/resultcode.rs new file mode 100644 index 0000000..ab2edc4 --- /dev/null +++ b/satrs-core/src/resultcode.rs @@ -0,0 +1,36 @@ +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct ResultU16 { + group_id: u8, + unique_id: u8, +} + +impl ResultU16 { + pub const fn const_new(group_id: u8, unique_id: u8) -> Self { + Self { + group_id, + unique_id, + } + } + pub fn raw(&self) -> u16 { + ((self.group_id as u16) << 8) | self.unique_id as u16 + } + pub fn group_id(&self) -> u8 { + self.group_id + } + pub fn unique_id(&self) -> u8 { + self.unique_id + } +} + +#[derive(Debug)] +pub struct ResultU16Ext { + pub name: &'static str, + pub result: ResultU16, + pub info: &'static str, +} + +impl ResultU16Ext { + pub const fn const_new(name: &'static str, result: ResultU16, info: &'static str) -> Self { + Self { name, result, info } + } +} diff --git a/satrs-macros/src/lib.rs b/satrs-macros/src/lib.rs index e69de29..8b13789 100644 --- a/satrs-macros/src/lib.rs +++ b/satrs-macros/src/lib.rs @@ -0,0 +1 @@ +