CCSDS USLP (Unified Space Link Protocol) Transfer Frame- unified TM/TC/AOS
0
fork

Configure Feed

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

ocaml-uslp: rewrite README examples to typecheck

The blocks had stray [let () = \n let buf = ""] gaps and ran a missing
newline ([... encoded) Printf.printf]). Wrap each as
[decode_frame buf] / [encode_frame ()] / [decode_with_crc32 buf],
switch [Printf.printf] to [Fmt.pr] / [Fmt.epr], and add [fmt] to
the mdx libraries.

+21 -23
+20 -22
README.md
··· 27 27 ## Usage 28 28 29 29 ```ocaml 30 - (* Decode a USLP frame *) 31 - let () = 32 - 33 - let buf = "" 34 - match Uslp.decode buf with 35 - | Error e -> Printf.printf "Error: %a\n" Uslp.pp_error e 30 + (* Decode a USLP frame. *) 31 + let decode_frame buf = 32 + match Uslp.decode buf with 33 + | Error e -> Fmt.epr "Error: %a@." Uslp.pp_error e 36 34 | Ok frame -> 37 - Printf.printf "SCID: %d, VCID: %d, MAP: %d\n" 35 + Fmt.pr "SCID: %d, VCID: %d, MAP: %d@." 38 36 (Uslp.scid_to_int frame.header.scid) 39 37 (Uslp.vcid_to_int frame.header.vcid) 40 38 (Uslp.map_id_to_int frame.header.map_id) 41 39 42 - (* Create and encode a USLP frame *) 43 - let () = 44 - 45 - let scid = Uslp.scid_exn 1000 46 - let vcid = Uslp.vcid_exn 5 47 - let map_id = Uslp.map_id_exn 3 48 - let frame = Uslp.v ~scid ~vcid ~map_id ~vcfc:12345 ~vcfc_len:2 "payload" 49 - let encoded = Uslp.encode ~fecf:Uslp.Crc16 frame Printf.printf "Encoded: %d bytes\n" (String.length encoded) 40 + (* Create and encode a USLP frame. *) 41 + let encode_frame () = 42 + let scid = Uslp.scid_exn 1000 in 43 + let vcid = Uslp.vcid_exn 5 in 44 + let map_id = Uslp.map_id_exn 3 in 45 + let frame = 46 + Uslp.v ~scid ~vcid ~map_id ~vcfc:12345 ~vcfc_len:2 "payload" 47 + in 48 + let encoded = Uslp.encode ~fecf:Uslp.Crc16 frame in 49 + Fmt.pr "Encoded: %d bytes@." (String.length encoded) 50 50 51 - (* Decode with VCFC and CRC-32 *) 52 - let () = 53 - 54 - let buf = "" 55 - match Uslp.decode ~vcfc_len:2 ~expect_fecf:Uslp.Crc32 buf with 56 - | Error e -> Printf.printf "Error: %a\n" Uslp.pp_error e 57 - | Ok frame -> Printf.printf "VCFC: %d\n" frame.header.vcfc 51 + (* Decode with VCFC and CRC-32. *) 52 + let decode_with_crc32 buf = 53 + match Uslp.decode ~vcfc_len:2 ~expect_fecf:Uslp.Crc32 buf with 54 + | Error e -> Fmt.epr "Error: %a@." Uslp.pp_error e 55 + | Ok frame -> Fmt.pr "VCFC: %d@." frame.header.vcfc 58 56 ``` 59 57 60 58 ## Frame Format
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries uslp)) 7 + (libraries uslp fmt))