impl EcssEnumeration for Event
This commit is contained in:
parent
4d415cc0ad
commit
0c9571f290
@ -1,5 +1,8 @@
|
||||
//! Event support module
|
||||
|
||||
use spacepackets::{ByteConversionError, SizeMissmatch};
|
||||
use spacepackets::ecss::EcssEnumeration;
|
||||
|
||||
pub type GroupId = u16;
|
||||
pub type UniqueId = u16;
|
||||
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)]
|
||||
mod tests {
|
||||
use super::Event;
|
||||
|
Loading…
Reference in New Issue
Block a user