Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ repository = "https://github.com/RustSpaceLab/xtce-gs"
authors = ["Maciej Myszkiewicz"]

[workspace.dependencies]
xtce-gs-core = { path = "crates/xtce-gs-core", version = "0.1.0" }
xtce-gs-link = { path = "crates/xtce-gs-link", version = "0.1.0" }
xtce-gs-engine = { path = "crates/xtce-gs-engine", version = "0.1.0" }
xtce-gs-gui = { path = "crates/xtce-gs-gui", version = "0.1.0" }
xtce-gs-core = { path = "crates/xtce-gs-core", version = "0.1.1" }
xtce-gs-link = { path = "crates/xtce-gs-link", version = "0.1.1" }
xtce-gs-engine = { path = "crates/xtce-gs-engine", version = "0.1.1" }
xtce-gs-gui = { path = "crates/xtce-gs-gui", version = "0.1.1" }

# Pinned to a revision, not a branch, and not a path. `xtce-rs` is where the decoder lives and
# this repository is built against one state of it; a moving dependency would mean an
Expand Down
14 changes: 6 additions & 8 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file is the index: the identifier, where it is, and one line of what it is.

```console
$ grep -rn "TODO(gs-link-rs-erasures)" crates/ # the full text of any entry
$ grep -rn "TODO(" crates/ | wc -l # 29 of them, over 21 identifiers
$ grep -rn "TODO(" crates/ | wc -l # 28 of them, over 20 identifiers
```

Nothing here is a bug. The bugs found while building this are in
Expand All @@ -19,12 +19,11 @@ Ordered by how much you learn per hour spent, not by importance.

| | Entry | Why it is a good one to pick up |
|---|---|---|
| 1 | `gs-link-frame-sh-zero` | A secondary header of length zero is malformed (§4.1.3.2 says 1–63 octets) and is accepted. Small, self-contained, and it makes you read one page of a Blue Book and decide what a malformed frame costs. |
| 2 | `gs-gui-layout` (`layout.rs:159`) | A panel the operator drags wider is narrow again next run. egui 0.35 has no public accessor for the dragged size, so the answer is to read it off the panel's own response rect — which means finding out how egui reports what it laid out. |
| 3 | `gs-engine-sctime-submilli` | A sub-millisecond field is refused on its width and not its value, so an out-of-range count pushes the instant past the millisecond it belongs in. Needs a ruling: drop the sample, or clamp it. |
| 4 | `gs-link-rs-shortened` | Virtual fill, CCSDS 131.0-B-5 §4.3.7. The arithmetic is a `pad` count; the work is threading a config field through `RsConfig` into the Chien search. Real Reed-Solomon work with a small blast radius. |
| 5 | `gs-link-frame-aos` | AOS transfer frames (CCSDS 732.0-B), which is what a great many CubeSats actually downlink. A second parser and a `Framing::AosFrames`, and the decision is whether the pipeline keeps one frame type with a discriminant or two. The biggest thing left that is not gated on hardware. |
| 6 | `gs-link-rs-erasures` | 2E erasures instead of E errors is most of the coding gain on a fading link. Needs a demodulator that reports confidence, which needs the link's input type to change. Do it when you have a radio that tells you. |
| 1 | `gs-gui-layout` (`layout.rs:159`) | A panel the operator drags wider is narrow again next run. egui 0.35 has no public accessor for the dragged size, so the answer is to read it off the panel's own response rect — which means finding out how egui reports what it laid out. |
| 2 | `gs-engine-sctime-submilli` | A sub-millisecond field is refused on its width and not its value, so an out-of-range count pushes the instant past the millisecond it belongs in. Needs a ruling: drop the sample, or clamp it. |
| 3 | `gs-link-rs-shortened` | Virtual fill, CCSDS 131.0-B-5 §4.3.7. The arithmetic is a `pad` count; the work is threading a config field through `RsConfig` into the Chien search. Real Reed-Solomon work with a small blast radius. |
| 4 | `gs-link-frame-aos` | AOS transfer frames (CCSDS 732.0-B), which is what a great many CubeSats actually downlink. A second parser and a `Framing::AosFrames`, and the decision is whether the pipeline keeps one frame type with a discriminant or two. The biggest thing left that is not gated on hardware. |
| 5 | `gs-link-rs-erasures` | 2E erasures instead of E errors is most of the coding gain on a fading link. Needs a demodulator that reports confidence, which needs the link's input type to change. Do it when you have a radio that tells you. |

## `xtce-gs-link`

Expand All @@ -36,7 +35,6 @@ Ordered by how much you learn per hour spent, not by importance.
| `gs-link-rs-shortened` | `rs.rs:804` | Virtual fill for shortened codeblocks. Needs a `virtual_fill` on `RsConfig` first; inferring it from the frame length is wrong. |
| `gs-link-frame-aos` | `frame.rs:220` | AOS frames (CCSDS 732.0-B) are refused at the version check rather than misread. Its VCID is six bits, so it needs a second parser, not a widened field. |
| `gs-link-frame-vca` | `frame.rs:298` | A frame with the sync flag set carries VCA service data, not packets, and its first-header-pointer is undefined. Decide whether the pipeline drops such frames or routes them. |
| `gs-link-frame-sh-zero` | `frame.rs:347` | A secondary header of length zero is malformed (§4.1.3.2 says 1–63 octets) and is accepted rather than refused. |
| `gs-link-frame-ocf-mismatch` | `frame.rs:377` | A frame whose OCF flag disagrees with the configuration is decoded by the flag and not reported. Decide: per frame (noisy) or latched per virtual channel. |
| `gs-link-packets` | `packets.rs:495` | Does any mission send only-idle-data frames *between* the frames of one long packet? Guessing wrong either splices two packets or loses one per idle frame. |
| `gs-link-csp` | `csp.rs:288` | An RDP packet is passed through with its five-octet trailer still on the payload, which desynchronises the packet stream behind it. Refuse or strip. |
Expand Down
32 changes: 23 additions & 9 deletions crates/xtce-gs-link/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,16 @@ impl<'a> TmFrame<'a> {

// Everything between the insert zone and the trailers: the secondary header and the
// data field share it, so a secondary header longer than this has eaten the checksum.
// CCSDS 132.0-B-3 §4.1.3.1.3 b) also requires the secondary header data field to carry
// 1 to 63 octets, so the six-bit length field cannot be zero and a one-octet secondary
// header is malformed.
let available = bytes
.len()
.saturating_sub(PRIMARY_HEADER_BYTES)
.saturating_sub(options.insert_zone)
.saturating_sub(frame.trailer_bytes());
let declared = frame.secondary_header_bytes();
if declared > available {
if (frame.secondary_header_flag() && declared < 2) || declared > available {
return Err(FrameError::BadSecondaryHeader {
declared,
available,
Expand Down Expand Up @@ -344,13 +347,6 @@ impl<'a> TmFrame<'a> {
PRIMARY_HEADER_BYTES.saturating_add(self.options.insert_zone)
}

// TODO(gs-link-frame-sh-zero): CCSDS 132.0-B-3 §4.1.3.1.3 b) gives the secondary header data
// field 1 to 63 octets, so the six-bit length field should never be zero and a one-octet
// secondary header is malformed. It is accepted here as one octet rather than refused,
// because refusing costs the frame and nothing downstream reads the secondary header.
// Refusing it needs a `FrameError` variant and a decision about whether the frame's packets
// are still worth having; the same question covers the two version bits of that octet, which
// §4.1.3.2.2.2 requires to be `00` and which are not checked either.
/// Length of the whole frame secondary header, its identification octet included.
///
/// CCSDS 132.0-B-3 §4.1.3.2.3.2: the low six bits of the first octet hold one less than
Expand Down Expand Up @@ -523,7 +519,7 @@ pub enum FrameError {
version: u8,
},

/// The secondary header declares a length that does not fit in the frame.
/// The secondary header declares a length that is malformed or does not fit in the frame.
#[error("frame secondary header declares {declared} bytes, {available} available")]
BadSecondaryHeader {
/// Length the header declares, its identification octet included.
Expand Down Expand Up @@ -819,6 +815,24 @@ mod tests {
);
}

#[test]
fn a_secondary_header_with_no_data_field_is_refused() {
// CCSDS 132.0-B-3 §4.1.3.1.3 b): the secondary header data field is 1 to 63 octets,
// so a secondary header declaring only its identification octet (low six bits zero)
// is malformed.
let mut bytes = vec![0x00, 0x00, 0x00, 0x00, 0x98, 0x00];
bytes.push(0x00);
bytes.extend_from_slice(&[0x00; 7]);
let bytes = seal(bytes);
assert_eq!(
TmFrame::parse(&bytes, PLAIN).unwrap_err(),
FrameError::BadSecondaryHeader {
declared: 1,
available: 8
}
);
}

#[test]
fn a_secondary_header_longer_than_the_frame_is_refused() {
// Flagged, declaring 64 octets, in a frame with 8 bytes between header and checksum.
Expand Down
Loading