Function ccsds::read_packet_groups
source · pub fn read_packet_groups(
reader: Box<dyn Read + Send>
) -> impl Iterator<Item = IOResult<PacketGroup>>Expand description
Return an Iterator that groups read packets into PacketGroups.
This is necessary for packet streams containing APIDs that utilize packet grouping sequence flags values SEQ_FIRST, SEQ_CONTINUATION, and SEQ_LAST. It can also be used for non-grouped APIDs (SEQ_UNSEGMENTED), however, it is not necessary in such cases. See PrimaryHeader::sequence_flags.
§Examples
Reading packets from data file of space packets (level-0) would look something like this:
use ccsds::read_packet_groups;
// data file stand-in
let dat: &[u8] = &[
// primary header bytes
0xd, 0x59, 0xd2, 0xab, 0x0, 07,
// CDS timecode bytes in secondary header
0x52, 0xc0, 0x0, 0x0, 0x0, 0xa7, 0x0, 0xdb, 0xff,
// minimum 1 byte of user data
0xff
];
let r = std::io::BufReader::new(dat);
read_packet_groups(Box::new(r)).for_each(|zult| {
let packet = zult.unwrap();
assert_eq!(packet.apid, 1369);
});