CCSDS TM Transfer Frames (CCSDS 132.0-B-3)
0
fork

Configure Feed

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

ocaml-tm: rewrite README CLCW example against the real API

[Tm.clcw] is the constructor; the extractor is [Tm.extract_clcw],
which returns [(Clcw.t, Clcw.error) result option]. The CLCW record
has [report_value] and [lockout] at top level (no [flags]). Add
[clcw] / [fmt] to the mdx libs and switch [Format.printf] /
[Printf.printf] / [print_endline] to [Fmt.pr] / [Fmt.epr].

+16 -15
+15 -14
README.md
··· 39 39 ## Usage 40 40 41 41 ```ocaml 42 - (* Create a TM frame *) 42 + (* Create a TM frame. *) 43 43 let scid = Tm.scid_exn 100 44 44 let vcid = Tm.vcid_exn 2 45 45 let data = String.make 1103 '\x00' 46 46 let frame = Tm.v ~scid ~vcid ~mcfc:1 ~vcfc:2 data 47 - (* Encode to bytes *) 48 47 let bytes = Tm.encode frame 49 - (* Decode from bytes *) 50 - match Tm.decode bytes with 51 - | Ok frame -> Printf.printf "SCID: %d\n" (Tm.scid_to_int frame.header.scid) 52 - | Error e -> Format.printf "Error: %a\n" Tm.pp_error e 48 + 49 + let () = 50 + match Tm.decode bytes with 51 + | Ok frame -> Fmt.pr "SCID: %d@." (Tm.scid_to_int frame.header.scid) 52 + | Error e -> Fmt.epr "Error: %a@." Tm.pp_error e 53 53 ``` 54 54 55 55 ### Working with CLCW 56 56 57 57 ```ocaml 58 - (* Extract CLCW from frame OCF *) 59 - match Tm.clcw frame with 60 - | None -> print_endline "No OCF present" 61 - | Some (Error _e) -> print_endline "Invalid CLCW in OCF" 62 - | Some (Ok clcw) -> 63 - Printf.printf "Report value (N(R)): %d\n" clcw.report_value; 64 - if clcw.flags.lockout then print_endline "FARM-1 in lockout!" 58 + (* Extract CLCW from frame OCF. *) 59 + let () = 60 + match Tm.extract_clcw frame with 61 + | None -> Fmt.pr "No OCF present@." 62 + | Some (Error _) -> Fmt.pr "Invalid CLCW in OCF@." 63 + | Some (Ok (clcw : Clcw.t)) -> 64 + Fmt.pr "Report value (N(R)): %d@." clcw.report_value; 65 + if clcw.lockout then Fmt.pr "FARM-1 in lockout!@." 65 66 66 - (* Create a CLCW *) 67 + (* Create a CLCW. *) 67 68 let clcw = Tm.clcw ~vcid ~report_value:42 ~lockout:false () 68 69 let ocf_word = Tm.encode_clcw clcw 69 70 ```
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries tm)) 7 + (libraries tm clcw fmt))