continue dest handler
All checks were successful
Rust/sat-rs/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2023-07-25 00:43:45 +02:00
parent 2213a25508
commit 6c87ae0b67
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -1,12 +1,24 @@
use super::{State, TransactionStep}; use super::{State, TransactionStep};
use spacepackets::cfdp::{pdu::FileDirectiveType, PduType}; use spacepackets::cfdp::{
pdu::{CommonPduConfig, FileDirectiveType},
PduType,
};
pub struct DestinationHandler { pub struct DestinationHandler {
step: TransactionStep, step: TransactionStep,
state: State, state: State,
//pdu_conf: CommonPduConfig,
} }
impl DestinationHandler { impl DestinationHandler {
pub fn new() -> Self {
Self {
step: TransactionStep::Idle,
state: State::Idle,
//pdu_conf: CommonPduConfig::new_with_defaults(),
}
}
pub fn insert_packet( pub fn insert_packet(
&mut self, &mut self,
pdu_type: PduType, pdu_type: PduType,
@ -27,6 +39,7 @@ impl DestinationHandler {
pub fn handle_file_data(&mut self, raw_packet: &[u8]) -> Result<(), ()> { pub fn handle_file_data(&mut self, raw_packet: &[u8]) -> Result<(), ()> {
Ok(()) Ok(())
} }
pub fn handle_file_directive( pub fn handle_file_directive(
&mut self, &mut self,
pdu_directive: FileDirectiveType, pdu_directive: FileDirectiveType,
@ -38,8 +51,32 @@ impl DestinationHandler {
pub fn state_machine(&mut self) { pub fn state_machine(&mut self) {
match self.state { match self.state {
State::Idle => todo!(), State::Idle => todo!(),
State::BusyClass1Nacked => todo!(), State::BusyClass1Nacked => self.fsm_nacked(),
State::BusyClass2Acked => todo!(), State::BusyClass2Acked => todo!(),
} }
} }
fn fsm_nacked(&self) {
match self.step {
TransactionStep::Idle => {
// TODO: Should not happen. Determine what to do later
}
TransactionStep::TransactionStart => {}
TransactionStep::ReceivingFileDataPdus => todo!(),
TransactionStep::SendingAckPdu => todo!(),
TransactionStep::TransferCompletion => todo!(),
TransactionStep::SendingFinishedPdu => todo!(),
}
}
/// Get the step, which denotes the exact step of a pending CFDP transaction when applicable.
pub fn step(&self) -> TransactionStep {
self.step
}
/// Get the step, which denotes whether the CFDP handler is active, and which CFDP class
/// is used if it is active.
pub fn state(&self) -> State {
self.state
}
} }