eurosim-obsw/src/ccsds.rs

52 lines
1.3 KiB
Rust
Raw Permalink Normal View History

2023-03-09 09:54:21 +01:00
use crate::tmtc::{
MpscStoreAndSendError, PusTcSource, AOCS_APID, AOCS_HK_APID, CSS_APID, MGM_APID, MGT_APID,
PLD_APID, PUS_APID, PWR_APID, RWL_APID, STR_APID,
};
2023-02-15 14:57:43 +01:00
use log::warn;
use satrs_core::spacepackets::{CcsdsPacket, SpHeader};
2023-01-19 10:06:00 +01:00
use satrs_core::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc};
2022-12-15 14:57:29 +01:00
pub struct CcsdsReceiver {
pub tc_source: PusTcSource,
2022-12-15 14:57:29 +01:00
}
impl CcsdsPacketHandler for CcsdsReceiver {
type Error = MpscStoreAndSendError;
2022-12-15 14:57:29 +01:00
fn valid_apids(&self) -> &'static [u16] {
2023-03-09 09:54:21 +01:00
&[
PUS_APID,
PLD_APID,
PWR_APID,
AOCS_APID,
AOCS_HK_APID,
MGM_APID,
CSS_APID,
STR_APID,
MGT_APID,
RWL_APID,
]
2022-12-15 14:57:29 +01:00
}
fn handle_known_apid(
&mut self,
sp_header: &SpHeader,
tc_raw: &[u8],
) -> Result<(), Self::Error> {
if sp_header.apid() == PUS_APID {
return self.tc_source.pass_ccsds(sp_header, tc_raw);
2023-03-09 09:54:21 +01:00
} else {
return self.tc_source.pass_ccsds(sp_header, tc_raw);
2022-12-15 14:57:29 +01:00
}
}
fn handle_unknown_apid(
&mut self,
sp_header: &SpHeader,
_tc_raw: &[u8],
) -> Result<(), Self::Error> {
2023-02-15 14:57:43 +01:00
warn!("Unknown APID 0x{:x?} detected", sp_header.apid());
2022-12-15 14:57:29 +01:00
Ok(())
}
}