improve docs, better naming
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
This commit is contained in:
parent
29c0961fab
commit
62ebad12fa
@ -32,7 +32,7 @@ impl SpacePacketValidator for SimplePacketValidator {
|
||||
log::warn!("ignoring space packet with header {:?}", sp_header);
|
||||
// We could perform a CRC check.. but lets keep this simple and assume that TCP ensures
|
||||
// data integrity.
|
||||
SpValidity::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@ use crate::{tmtc::PacketSenderRaw, ComponentId};
|
||||
pub enum SpValidity {
|
||||
Valid,
|
||||
/// The space packet can be assumed to have a valid format, but the packet should
|
||||
/// be ignored.
|
||||
Ignore,
|
||||
/// be skipped.
|
||||
Skip,
|
||||
/// The space packet or space packet header has an invalid format, for example a CRC check
|
||||
/// failed. In that case, the parser loses the packet synchronization and needs to check for
|
||||
/// the start of a new space packet header start again. The space packet header
|
||||
@ -30,13 +30,16 @@ pub trait SpacePacketValidator {
|
||||
/// If broken tail packets are detected, they are moved to the front of the buffer, and the write
|
||||
/// index for future write operations will be written to the `next_write_idx` argument.
|
||||
///
|
||||
/// The parser will forward all packets for which the user provided [SpacePacketValidator] returned
|
||||
/// [SpacePacketValidation::Valid] to the given `packet_sender` and return the number of packets
|
||||
/// found. If the [PacketSenderRaw::send_packet] calls fails, the error will be returned.
|
||||
/// The parses will behave differently based on the [SpValidity] returned from the user provided
|
||||
/// [SpacePacketValidator]:
|
||||
///
|
||||
/// If the user provided [SpacePacketValidator] returns [SpacePacketValidation::Invalid], the
|
||||
/// parser assumes that the synchronization is lost and tries to find the start of a new space
|
||||
/// packet header by scanning all the following bytes.
|
||||
/// 1. [SpValidity::Valid]: The parser will forward all packets to the given `packet_sender` and
|
||||
/// return the number of packets found.If the [PacketSenderRaw::send_packet] calls fails, the
|
||||
/// error will be returned.
|
||||
/// 2. [SpValidity::Invalid]: The parser assumes that the synchronization is lost and tries to
|
||||
/// find the start of a new space packet header by scanning all the following bytes.
|
||||
/// 3. [SpValidity::Skip]: The parser skips the packet using the packet length determined from the
|
||||
/// space packet header.
|
||||
pub fn parse_buffer_for_ccsds_space_packets<SendError>(
|
||||
buf: &mut [u8],
|
||||
packet_validator: &(impl SpacePacketValidator + ?Sized),
|
||||
@ -71,7 +74,7 @@ pub fn parse_buffer_for_ccsds_space_packets<SendError>(
|
||||
current_idx += packet_size;
|
||||
continue;
|
||||
}
|
||||
SpValidity::Ignore => {
|
||||
SpValidity::Skip => {
|
||||
current_idx += sp_header.total_len();
|
||||
}
|
||||
// We might have lost sync. Try to find the start of a new space packet header.
|
||||
@ -92,9 +95,7 @@ mod tests {
|
||||
|
||||
use crate::{encoding::tests::TcCacher, ComponentId};
|
||||
|
||||
use super::{
|
||||
parse_buffer_for_ccsds_space_packets, SpValidity, SpacePacketValidator,
|
||||
};
|
||||
use super::{parse_buffer_for_ccsds_space_packets, SpValidity, SpacePacketValidator};
|
||||
|
||||
const PARSER_ID: ComponentId = 0x05;
|
||||
const TEST_APID_0: u16 = 0x02;
|
||||
@ -122,7 +123,7 @@ mod tests {
|
||||
{
|
||||
return SpValidity::Valid;
|
||||
}
|
||||
SpValidity::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ mod tests {
|
||||
return SpValidity::Valid;
|
||||
}
|
||||
// Simple case: Assume that the interface always contains valid space packets.
|
||||
SpValidity::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ use spacepackets::{
|
||||
ecss::{
|
||||
tc::PusTcReader,
|
||||
tm::{PusTmCreator, PusTmReader},
|
||||
WritablePusPacket,
|
||||
},
|
||||
SpHeader,
|
||||
};
|
||||
@ -226,6 +225,7 @@ pub mod std_mod {
|
||||
|
||||
#[cfg(feature = "crossbeam")]
|
||||
use crossbeam_channel as cb;
|
||||
use spacepackets::ecss::WritablePusPacket;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::pool::PoolProvider;
|
||||
|
@ -209,7 +209,7 @@ impl SpacePacketValidator for SimpleVerificator {
|
||||
if self.valid_ids.contains(&sp_header.packet_id()) {
|
||||
return SpValidity::Valid;
|
||||
}
|
||||
SpValidity::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user