PUS Event Generation #17

Merged
muellerr merged 13 commits from event-pus-generation into main 2022-10-22 17:34:00 +02:00
Showing only changes of commit 0c9571f290 - Show all commits

View File

@ -1,5 +1,8 @@
//! Event support module //! Event support module
use spacepackets::{ByteConversionError, SizeMissmatch};
use spacepackets::ecss::EcssEnumeration;
pub type GroupId = u16; pub type GroupId = u16;
pub type UniqueId = u16; pub type UniqueId = u16;
pub type EventRaw = u32; pub type EventRaw = u32;
@ -91,6 +94,22 @@ impl TryFrom<EventRaw> for Event {
} }
} }
impl EcssEnumeration for Event {
fn pfc(&self) -> u8 {
32
}
fn write_to_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> {
if buf.len() < self.byte_width() {
return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch {
found: buf.len(),
expected: self.byte_width()
}))
}
Ok(buf.copy_from_slice(self.raw().to_be_bytes().as_slice()))
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Event; use super::Event;