stupid windows
This commit is contained in:
@ -17,6 +17,10 @@ delegate = ">=0.8, <0.10"
|
||||
paste = "1"
|
||||
embed-doc-image = "0.1"
|
||||
|
||||
[dependencies.num_enum]
|
||||
version = "0.5"
|
||||
default-features = false
|
||||
|
||||
[dependencies.dyn-clone]
|
||||
version = "1"
|
||||
optional = true
|
||||
@ -78,7 +82,8 @@ std = [
|
||||
"postcard/use-std",
|
||||
"crossbeam-channel/std",
|
||||
"serde/std",
|
||||
"spacepackets/std"
|
||||
"spacepackets/std",
|
||||
"num_enum/std"
|
||||
]
|
||||
alloc = [
|
||||
"serde/alloc",
|
||||
|
@ -1,18 +1,61 @@
|
||||
use core::mem::size_of;
|
||||
use crate::tmtc::TargetId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use spacepackets::{ByteConversionError, SizeMissmatch};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct ModePair {
|
||||
pub struct ModeAndSubmode {
|
||||
mode: u32,
|
||||
submode: u16,
|
||||
}
|
||||
|
||||
impl ModeAndSubmode {
|
||||
pub const fn new_mode_only(mode: u32) -> Self {
|
||||
Self {
|
||||
mode,
|
||||
submode: 0
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn new(mode: u32, submode: u16) -> Self {
|
||||
Self {
|
||||
mode,
|
||||
submode
|
||||
}
|
||||
}
|
||||
|
||||
pub fn raw_len() -> usize {
|
||||
size_of::<u32>() + size_of::<u16>()
|
||||
}
|
||||
|
||||
pub fn from_be_bytes(buf: &[u8]) -> Result<Self, ByteConversionError> {
|
||||
if buf.len() < 6 {
|
||||
return Err(ByteConversionError::FromSliceTooSmall(SizeMissmatch {
|
||||
expected: 6,
|
||||
found: buf.len()
|
||||
}));
|
||||
}
|
||||
Ok(Self {
|
||||
mode: u32::from_be_bytes(buf[0..4].try_into().unwrap()),
|
||||
submode: u16::from_be_bytes(buf[4..6].try_into().unwrap())
|
||||
})
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct ModeCommand {
|
||||
address: TargetId,
|
||||
mode: ModePair,
|
||||
mode_submode: ModeAndSubmode,
|
||||
}
|
||||
|
||||
impl ModeCommand {
|
||||
pub const fn new(address: TargetId, mode_submode: ModeAndSubmode) -> Self {
|
||||
Self {
|
||||
address,
|
||||
mode_submode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
|
@ -11,6 +11,7 @@ use spacepackets::{ByteConversionError, SizeMissmatch};
|
||||
pub mod event;
|
||||
pub mod event_man;
|
||||
pub mod hk;
|
||||
pub mod mode;
|
||||
#[cfg(feature = "std")]
|
||||
pub mod scheduling;
|
||||
pub mod verification;
|
||||
|
16
satrs-core/src/pus/mode.rs
Normal file
16
satrs-core/src/pus/mode.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use num_enum::{IntoPrimitive, TryFromPrimitive};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, IntoPrimitive, TryFromPrimitive)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[repr(u8)]
|
||||
pub enum Subservice {
|
||||
TcSetMode = 1,
|
||||
TcReadMode = 3,
|
||||
TcAnnounceMode = 4,
|
||||
TcAnnounceModeRecursive = 5,
|
||||
TmModeReply = 6,
|
||||
TmCantReachMode = 7,
|
||||
TmWrongModeReply = 8,
|
||||
}
|
Reference in New Issue
Block a user