new mib crate

This commit is contained in:
2022-11-27 22:05:42 +01:00
parent 7e0d3f394a
commit b0b41a07dc
19 changed files with 341 additions and 65 deletions

View File

@ -29,6 +29,10 @@ optional = true
version= "0.5"
default-features = false
[dependencies.serde]
version = "1.0"
default-features = false
[dependencies.spacepackets]
path = "../spacepackets"
@ -42,8 +46,8 @@ version = "1.0"
[features]
default = ["std"]
std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std"]
alloc = []
std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std", "serde/std"]
alloc = ["serde/alloc"]
heapless = []
doc-images = []

View File

@ -29,6 +29,6 @@ pub mod params;
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
pub mod pool;
pub mod pus;
pub mod resultcode;
pub mod res_code;
pub mod seq_count;
pub mod tmtc;

View File

@ -1,7 +1,8 @@
use serde::{Deserialize, Serialize};
use spacepackets::ecss::{EcssEnumU16, EcssEnumeration};
use spacepackets::{ByteConversionError, SizeMissmatch};
use spacepackets::ecss::{EcssEnumeration, EcssEnumU16};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ResultU16 {
group_id: u8,
unique_id: u8,
@ -40,7 +41,7 @@ impl EcssEnumeration for ResultU16 {
if buf.len() < 2 {
return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch {
found: buf.len(),
expected: 2
expected: 2,
}));
}
buf[0] = self.group_id;
@ -48,20 +49,3 @@ impl EcssEnumeration for ResultU16 {
Ok(())
}
}
#[derive(Debug)]
pub struct ResultU16Ext {
pub name: &'static str,
pub result: &'static ResultU16,
pub info: &'static str,
}
impl ResultU16Ext {
pub const fn const_new(
name: &'static str,
result: &'static ResultU16,
info: &'static str,
) -> Self {
Self { name, result, info }
}
}