diff --git a/satrs-core/Cargo.toml b/satrs-core/Cargo.toml index a26cf03..543039e 100644 --- a/satrs-core/Cargo.toml +++ b/satrs-core/Cargo.toml @@ -68,8 +68,8 @@ optional = true [dependencies.spacepackets] version = "0.7.0-beta.1" # path = "../../spacepackets" -# git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git" -# rev = "" +git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git" +rev = "79d26e1a6" # branch = "" default-features = false diff --git a/satrs-core/src/parsers/ccsds.rs b/satrs-core/src/parsers/ccsds.rs index 949a1cf..1a90a7b 100644 --- a/satrs-core/src/parsers/ccsds.rs +++ b/satrs-core/src/parsers/ccsds.rs @@ -2,36 +2,59 @@ use alloc::vec::Vec; #[cfg(feature = "alloc")] use hashbrown::HashSet; +use spacepackets::PacketId; use crate::tmtc::ReceivesTc; pub trait PacketIdLookup { - fn validate(&self, apid: u16) -> bool; + fn validate(&self, packet_id: u16) -> bool; } #[cfg(feature = "alloc")] impl PacketIdLookup for Vec { - fn validate(&self, apid: u16) -> bool { - self.contains(&apid) + fn validate(&self, packet_id: u16) -> bool { + self.contains(&packet_id) + } +} + +#[cfg(feature = "alloc")] +impl PacketIdLookup for Vec { + fn validate(&self, packet_id: u16) -> bool { + self.contains(&PacketId::from(packet_id)) } } #[cfg(feature = "alloc")] impl PacketIdLookup for HashSet { - fn validate(&self, apid: u16) -> bool { - self.contains(&apid) + fn validate(&self, packet_id: u16) -> bool { + self.contains(&packet_id) + } +} + +#[cfg(feature = "alloc")] +impl PacketIdLookup for HashSet { + fn validate(&self, packet_id: u16) -> bool { + self.contains(&PacketId::from(packet_id)) } } impl PacketIdLookup for &[u16] { - fn validate(&self, apid: u16) -> bool { - if self.binary_search(&apid).is_ok() { + fn validate(&self, packet_id: u16) -> bool { + if self.binary_search(&packet_id).is_ok() { return true; } false } } +impl PacketIdLookup for &[PacketId] { + fn validate(&self, packet_id: u16) -> bool { + if self.binary_search(&PacketId::from(packet_id)).is_ok() { + return true; + } + false + } +} /// This function parses a given buffer for tightly packed CCSDS space packets. It uses the /// [PacketId] field of the CCSDS packets to detect the start of a CCSDS space packet and then /// uses the length field of the packet to extract CCSDS packets.