2023-01-18 10:04:36 +01:00
|
|
|
use crate::tmtc::{MpscStoreAndSendError, PusTcSource, PUS_APID};
|
|
|
|
use satrs_core::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc};
|
|
|
|
use satrs_core::spacepackets::{CcsdsPacket, SpHeader};
|
2022-12-15 14:57:29 +01:00
|
|
|
|
|
|
|
pub struct CcsdsReceiver {
|
2023-01-18 10:04:36 +01:00
|
|
|
pub tc_source: PusTcSource,
|
2022-12-15 14:57:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl CcsdsPacketHandler for CcsdsReceiver {
|
2023-01-18 10:04:36 +01:00
|
|
|
type Error = MpscStoreAndSendError;
|
2022-12-15 14:57:29 +01:00
|
|
|
|
|
|
|
fn valid_apids(&self) -> &'static [u16] {
|
|
|
|
&[PUS_APID]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn handle_known_apid(
|
|
|
|
&mut self,
|
|
|
|
sp_header: &SpHeader,
|
|
|
|
tc_raw: &[u8],
|
|
|
|
) -> Result<(), Self::Error> {
|
|
|
|
if sp_header.apid() == PUS_APID {
|
2023-01-18 10:04:36 +01:00
|
|
|
return self.tc_source.pass_ccsds(sp_header, tc_raw);
|
2022-12-15 14:57:29 +01:00
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn handle_unknown_apid(
|
|
|
|
&mut self,
|
|
|
|
sp_header: &SpHeader,
|
|
|
|
_tc_raw: &[u8],
|
|
|
|
) -> Result<(), Self::Error> {
|
|
|
|
println!("Unknown APID 0x{:x?} detected", sp_header.apid());
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|