split up APID and packet ID validator
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
This commit is contained in:
parent
cdf546b85d
commit
0b4a88837c
@ -1,9 +1,9 @@
|
|||||||
use satrs::pus::ReceivesEcssPusTc;
|
use satrs::pus::ReceivesEcssPusTc;
|
||||||
use satrs::spacepackets::{CcsdsPacket, PacketId, SpHeader};
|
use satrs::spacepackets::{CcsdsPacket, SpHeader};
|
||||||
use satrs::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc};
|
use satrs::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc};
|
||||||
use satrs::ValidatorU16Id;
|
use satrs::ValidatorU16Id;
|
||||||
use satrs_example::config::components::Apid;
|
use satrs_example::config::components::Apid;
|
||||||
use satrs_example::config::PACKET_ID_VALIDATOR;
|
use satrs_example::config::APID_VALIDATOR;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CcsdsReceiver<
|
pub struct CcsdsReceiver<
|
||||||
@ -18,8 +18,8 @@ impl<
|
|||||||
E: 'static,
|
E: 'static,
|
||||||
> ValidatorU16Id for CcsdsReceiver<TcSource, E>
|
> ValidatorU16Id for CcsdsReceiver<TcSource, E>
|
||||||
{
|
{
|
||||||
fn validate(&self, packet_id: u16) -> bool {
|
fn validate(&self, apid: u16) -> bool {
|
||||||
PACKET_ID_VALIDATOR.contains(&PacketId::from(packet_id))
|
APID_VALIDATOR.contains(&apid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ impl<
|
|||||||
sp_header: &SpHeader,
|
sp_header: &SpHeader,
|
||||||
_tc_raw: &[u8],
|
_tc_raw: &[u8],
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
println!("Unknown APID 0x{:x?} detected", sp_header.apid());
|
log::warn!("unknown APID 0x{:x?} detected", sp_header.apid());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,13 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
};
|
};
|
||||||
|
pub static ref APID_VALIDATOR: HashSet<u16> = {
|
||||||
|
let mut set = HashSet::new();
|
||||||
|
for id in components::Apid::iter() {
|
||||||
|
set.insert(id as u16);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod tmtc_err {
|
pub mod tmtc_err {
|
||||||
|
Loading…
Reference in New Issue
Block a user