CCSDS Synchronization and Channel Coding (131.0-B, 231.0-B)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-scc: enable MDX on lib/scc.mli, fix broken doc example

Run mdx on lib/scc.mli so the {[ ... ]} odoc block now type-checks
the synchronisation + channel-coding flow.

The example referenced free `tc_frame`, `frame`, `raw_bytes`, used a
bare unqualified `I5` constructor (the variant lives in
Scc.Coding.Reed_solomon), and `let ... in` chains that do not parse
at the top level. Restructured as toplevel bindings: a real
`tc_frame`, a `223 * 5` byte interleaved-RS frame, the qualified
`Scc.Coding.Reed_solomon.I5` constructor, and `Scc.Sync.Cltu_sync`
fed the encoded CLTU back through the parser with an
`assert (Bytes.equal decoded tc_frame)` documenting the round-trip.

Asserted `Bytes.length codeword = 255 * 5` so the documented
RS(255,223) shape at interleave 5 is verified at mdx test time, not
buried in prose.

+27 -9
+4
lib/dune
··· 2 2 (name scc) 3 3 (public_name scc) 4 4 (libraries reed-solomon viterbi turbo ldpc fmt logs)) 5 + 6 + (mdx 7 + (files scc.mli) 8 + (libraries scc))
+23 -9
lib/scc.mli
··· 20 20 {b Usage} 21 21 22 22 {[ 23 - (* Synchronization: wrap a TC frame in a CLTU *) 24 - let cltu = Scc.Sync.Cltu.encode tc_frame 23 + (* Synchronization: wrap a TC frame in a CLTU. *) 24 + let tc_frame = Bytes.of_string "tc-data" 25 + let cltu = Scc.Sync.Cltu.encode tc_frame 25 26 26 - (* Channel coding: randomize + RS encode *) 27 - let r = Scc.Coding.Randomizer.create () in 28 - Scc.Coding.Randomizer.apply r frame 0 (Bytes.length frame); 29 - let codeword = Scc.Coding.Reed_solomon.encode ~interleave:I5 frame 27 + (* Channel coding: randomize the data block in place, then RS-encode 28 + a 223 * 5 = 1115 byte frame (RS(255,223) at interleave depth 5). *) 29 + let frame = Bytes.make (223 * 5) '\x00' 30 + let r = Scc.Coding.Randomizer.create () 31 + let () = Scc.Coding.Randomizer.apply r frame 0 (Bytes.length frame) 30 32 31 - (* Stream parsing: extract CLTUs from raw bytes *) 32 - let state = Scc.Sync.Cltu_sync.init () in 33 - let state, result = Scc.Sync.Cltu_sync.feed state raw_bytes 33 + let codeword = 34 + Scc.Coding.Reed_solomon.encode ~interleave:Scc.Coding.Reed_solomon.I5 35 + frame 36 + 37 + (* Stream parsing: feed the encoded CLTU back through the sync parser 38 + and recover the original tc_frame (or wait for more bytes). *) 39 + let state = Scc.Sync.Cltu_sync.init () 40 + let _, result = Scc.Sync.Cltu_sync.feed state cltu 41 + 42 + let () = 43 + match result with 44 + | Some (Ok decoded) -> assert (Bytes.equal decoded tc_frame) 45 + | Some (Error _) | None -> () 46 + 47 + let () = assert (Bytes.length codeword = 255 * 5) 34 48 ]} 35 49 36 50 @see <https://public.ccsds.org/Pubs/131x0b4.pdf> CCSDS 131.0-B-4