Skip to content

Commit

Permalink
fix filtering after/before
Browse files Browse the repository at this point in the history
  • Loading branch information
bmflynn committed Nov 9, 2024
1 parent 4c6d2db commit 0e97f96
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions ccsds-cmd/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
use anyhow::{bail, Result};
use ccsds::{Apid, CdsTimeDecoder, TimeDecoder};
use hifitime::{Duration, Epoch};
use tracing::trace;

struct Ptr(Vec<u8>, Apid, Epoch);

Expand Down Expand Up @@ -82,25 +83,54 @@ where
let have_after = after.is_some();
let after = after.unwrap_or(min_epoch);

for Ptr(data, apid, epoch) in packets {
if have_before && have_after && (epoch < before || epoch > after) {
for Ptr(data, apid, stamp) in packets {
if have_before && have_after && stamp < after || stamp >= before {
trace!(
apid,
?stamp,
len = data.len(),
?before,
?after,
"skip after/before"
);
continue;
}
if have_before && epoch < before {
} else if have_before && stamp >= before {
trace!(
apid,
?stamp,
len = data.len(),
?before,
?after,
"skip before"
);
continue;
}
if have_after && epoch > after {
} else if have_after && stamp < after {
trace!(
apid,
?stamp,
len = data.len(),
?before,
?after,
"skip after"
);
continue;
}
if including && excluding {
if include.contains(&apid) && !exclude.contains(&apid) {
writer.write_all(&data)?;
} else {
trace!(
apid,
?stamp,
len = data.len(),
"skip included, not excluded"
);
}
} else if (including && include.contains(&apid)) || (excluding && !exclude.contains(&apid))
} else if (including && include.contains(&apid))
|| (excluding && !exclude.contains(&apid))
|| !(including || excluding)
{
writer.write_all(&data)?;
} else if !excluding && !including {
writer.write_all(&data)?;
}
}

Expand Down

0 comments on commit 0e97f96

Please sign in to comment.