SpaceWire (ECSS-E-ST-50-12C) and RMAP (ECSS-E-ST-50-52C)
0
fork

Configure Feed

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

ocaml-spacewire: rewrite README examples to typecheck

Top-level [match] expressions don't parse; wrap each in
[let () = match ...] and switch [Printf.printf] to [Fmt.pr] /
[Fmt.epr], adding [fmt] to the mdx libraries.

+20 -18
+19 -17
README.md
··· 43 43 ## Usage 44 44 45 45 ```ocaml 46 - (* Create and encode a SpaceWire packet *) 47 - let pkt = Spacewire.packet_exn ~address:[1; 5] ~cargo:"sensor data" EOP 46 + (* Create and encode a SpaceWire packet. *) 47 + let pkt = Spacewire.packet_exn ~address:[ 1; 5 ] ~cargo:"sensor data" EOP 48 48 let bytes = Spacewire.encode_packet pkt 49 - (* Decode *) 50 - match Spacewire.decode_packet bytes with 51 - | Ok decoded -> Printf.printf "cargo: %s\n" (Spacewire.cargo decoded) 52 - | Error _ -> Printf.printf "decode error\n" 49 + 50 + let () = 51 + match Spacewire.decode_packet bytes with 52 + | Ok decoded -> Fmt.pr "cargo: %s@." (Spacewire.cargo decoded) 53 + | Error _ -> Fmt.epr "decode error@." 53 54 ``` 54 55 55 56 ```ocaml 56 - (* RMAP read command *) 57 + (* RMAP read command. *) 57 58 let cmd = 58 - Spacewire.rmap_command_exn 59 - ~command:Read ~ack:Ack ~increment:Increment 60 - ~key:42 ~initiator_logical_address:0xFE 61 - ~transaction_id:1 ~address:0x1000L ~data_length:256 () 62 - in 59 + Spacewire.rmap_command_exn ~command:Read ~ack:Ack ~increment:Increment 60 + ~key:42 ~initiator_logical_address:0xFE ~transaction_id:1 61 + ~address:0x1000L ~data_length:256 () 62 + 63 63 let encoded = Spacewire.encode_rmap_command ~target_logical_address:0x50 cmd 64 - match Spacewire.decode_rmap_command encoded with 65 - | Ok (target, decoded) -> 66 - Printf.printf "target: 0x%02X, tid: %d\n" 67 - target (Spacewire.rmap_cmd_transaction_id decoded) 68 - | Error _ -> Printf.printf "decode error\n" 64 + 65 + let () = 66 + match Spacewire.decode_rmap_command encoded with 67 + | Ok (target, decoded) -> 68 + Fmt.pr "target: 0x%02X, tid: %d@." target 69 + (Spacewire.rmap_cmd_transaction_id decoded) 70 + | Error _ -> Fmt.epr "decode error@." 69 71 ``` 70 72 71 73 ## Protocol Layers
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries spacewire)) 7 + (libraries spacewire fmt))