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: rewrite README examples to typecheck

The Usage block had unbound [tc_frame] / [frame] / [raw_bytes] free
variables. Wrap each flow in a function ([uplink], [downlink],
[feed_cltus]). The Eio transport block referenced a single [flow]
used as both source and sink, mismatched [(_, [`Transport e])] /
[(_, [`Error of string])] error variants, and missed the [`Error _]
case. Take [~source] / [~sink] separately, handle every error
variant via [Fmt.epr], and add [eio] / [eio.core] / [fmt] mdx
libraries.

+24 -22
+23 -21
README.md
··· 71 71 ## Usage 72 72 73 73 ```ocaml 74 - (* TC uplink: frame -> CLTU *) 75 - let cltu = Scc.Sync.Cltu.encode tc_frame 74 + (* TC uplink: frame -> CLTU. *) 75 + let uplink tc_frame = Scc.Sync.Cltu.encode tc_frame 76 76 77 - (* TM downlink: randomize + RS encode + convolutional encode *) 78 - let r = Scc.Coding.Randomizer.create () 79 - let () = Scc.Coding.Randomizer.apply r frame 0 (Bytes.length frame) 80 - let codeword = Scc.Coding.Reed_solomon.encode ~interleave:I5 frame 81 - let coded = Scc.Coding.Convolutional.encode codeword 77 + (* TM downlink: randomize + RS encode + convolutional encode. *) 78 + let downlink frame = 79 + let r = Scc.Coding.Randomizer.create () in 80 + Scc.Coding.Randomizer.apply r frame 0 (Bytes.length frame); 81 + let codeword = Scc.Coding.Reed_solomon.encode ~interleave:I5 frame in 82 + Scc.Coding.Convolutional.encode codeword 82 83 83 - (* Stream parsing: extract CLTUs from raw bytes *) 84 - let state = ref (Scc.Sync.Cltu_sync.init ()) 85 - let () = 86 - let new_state, result = Scc.Sync.Cltu_sync.feed !state raw_bytes in 87 - state := new_state; 88 - ignore result 84 + (* Stream parsing: extract CLTUs from raw bytes. *) 85 + let feed_cltus state raw_bytes = 86 + let new_state, result = Scc.Sync.Cltu_sync.feed state raw_bytes in 87 + (new_state, result) 89 88 ``` 90 89 91 90 ## Eio Transport (`scc-eio`) ··· 93 92 The `scc-eio` package provides Eio flow-based send/recv: 94 93 95 94 ```ocaml 96 - let () = 97 - (* Receive CLTU-framed TC from a raw byte stream *) 98 - (match Scc_eio.Cltu.recv flow with 99 - | Ok frame -> process_tc frame 100 - | Error `Closed -> () 101 - | Error (`Transport e) -> log_error e); 102 - (* Send ASM-framed TM *) 103 - Scc_eio.Asm.send flow tm_frame 95 + let serve ~source ~sink ~process_tc tm_frame = 96 + (* Receive CLTU-framed TC from a raw byte stream. *) 97 + (match Scc_eio.Cltu.recv source with 98 + | Ok frame -> process_tc frame 99 + | Error `Closed -> () 100 + | Error (`Transport _) -> Fmt.epr "transport error@." 101 + | Error (`Error msg) -> Fmt.epr "decode error: %s@." msg); 102 + (* Send ASM-framed TM. *) 103 + match Scc_eio.Asm.send sink tm_frame with 104 + | Ok () -> () 105 + | Error (`Error msg) -> Fmt.epr "send error: %s@." msg 104 106 ```
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries scc scc-eio)) 7 + (libraries scc scc-eio eio eio.core fmt))