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.

mass replace Printf.sprintf/printf with Fmt.str/pr (merlint E200)

112 files across the monorepo. Printf.sprintf → Fmt.str,
Printf.printf → Fmt.pr for consistent formatting library usage.

+17 -17
+2 -2
test/interop/dariol83/test.ml
··· 17 17 let hex_of_bytes b = 18 18 let buf = Buffer.create (Bytes.length b * 2) in 19 19 Bytes.iter 20 - (fun c -> Buffer.add_string buf (Printf.sprintf "%02x" (Char.code c))) 20 + (fun c -> Buffer.add_string buf (Fmt.str "%02x" (Char.code c))) 21 21 b; 22 22 Buffer.contents buf 23 23 ··· 137 137 let got_hex = 138 138 let buf = Buffer.create (String.length got * 2) in 139 139 String.iter 140 - (fun c -> Buffer.add_string buf (Printf.sprintf "%02x" (Char.code c))) 140 + (fun c -> Buffer.add_string buf (Fmt.str "%02x" (Char.code c))) 141 141 got; 142 142 Buffer.contents buf 143 143 in
+12 -12
test/test_coding.ml
··· 55 55 let seq = Scc.Coding.Randomizer.sequence 40 in 56 56 for i = 0 to 39 do 57 57 Alcotest.(check int) 58 - (Printf.sprintf "PN byte %d" i) 58 + (Fmt.str "PN byte %d" i) 59 59 ccsds_pn_first_40.(i) 60 60 (Char.code (Bytes.get seq i)) 61 61 done ··· 66 66 for i = 0 to 254 do 67 67 let expected = Scc.Coding.Randomizer.next_byte r in 68 68 Alcotest.(check int) 69 - (Printf.sprintf "PN byte %d" i) 69 + (Fmt.str "PN byte %d" i) 70 70 expected 71 71 (Char.code (Bytes.get seq i)) 72 72 done ··· 120 120 let next_255 = Array.init 255 (fun _ -> Scc.Coding.Randomizer.next_byte r) in 121 121 for i = 0 to 254 do 122 122 Alcotest.(check int) 123 - (Printf.sprintf "period byte %d" i) 123 + (Fmt.str "period byte %d" i) 124 124 first_255.(i) next_255.(i) 125 125 done 126 126 ··· 130 130 Scc.Coding.Randomizer.apply r buf 4 8; 131 131 for i = 0 to 3 do 132 132 Alcotest.(check int) 133 - (Printf.sprintf "untouched byte %d" i) 133 + (Fmt.str "untouched byte %d" i) 134 134 0 135 135 (Char.code (Bytes.get buf i)) 136 136 done; 137 137 let pn = Scc.Coding.Randomizer.sequence 8 in 138 138 for i = 0 to 7 do 139 139 Alcotest.(check int) 140 - (Printf.sprintf "applied byte %d" (i + 4)) 140 + (Fmt.str "applied byte %d" (i + 4)) 141 141 (Char.code (Bytes.get pn i)) 142 142 (Char.code (Bytes.get buf (i + 4))) 143 143 done ··· 156 156 Alcotest.(check string) 157 157 "RS roundtrip I=1" (Bytes.to_string data) 158 158 (Bytes.to_string recovered) 159 - | Error e -> Alcotest.fail (Printf.sprintf "RS decode failed: %s" e) 159 + | Error e -> Alcotest.fail (Fmt.str "RS decode failed: %s" e) 160 160 161 161 let test_rs_roundtrip_i5 () = 162 162 let data = Bytes.init 1115 (fun i -> Char.chr (((i * 7) + 3) land 0xFF)) in ··· 167 167 Alcotest.(check string) 168 168 "RS roundtrip I=5" (Bytes.to_string data) 169 169 (Bytes.to_string recovered) 170 - | Error e -> Alcotest.fail (Printf.sprintf "RS decode I=5 failed: %s" e) 170 + | Error e -> Alcotest.fail (Fmt.str "RS decode I=5 failed: %s" e) 171 171 172 172 let test_rs_error_correction () = 173 173 let data = Bytes.init 223 (fun i -> Char.chr (((i * 13) + 42) land 0xFF)) in ··· 184 184 "RS corrects 16 errors" (Bytes.to_string data) 185 185 (Bytes.to_string recovered) 186 186 | Error e -> 187 - Alcotest.fail (Printf.sprintf "RS failed to correct 16 errors: %s" e) 187 + Alcotest.fail (Fmt.str "RS failed to correct 16 errors: %s" e) 188 188 189 189 let test_rs_error_correction_interleaved () = 190 190 let data = Bytes.init 1115 (fun i -> Char.chr (((i * 11) + 7) land 0xFF)) in ··· 205 205 "RS corrects interleaved errors" (Bytes.to_string data) 206 206 (Bytes.to_string recovered) 207 207 | Error e -> 208 - Alcotest.fail (Printf.sprintf "RS interleaved decode failed: %s" e) 208 + Alcotest.fail (Fmt.str "RS interleaved decode failed: %s" e) 209 209 210 210 let test_rs_uncorrectable_17_errors () = 211 211 let data = Bytes.init 223 (fun i -> Char.chr (((i * 13) + 42) land 0xFF)) in ··· 487 487 let seq = Scc.Coding.Randomizer.sequence 255 in 488 488 for i = 0 to 254 do 489 489 Alcotest.(check int) 490 - (Printf.sprintf "PN byte %d" i) 490 + (Fmt.str "PN byte %d" i) 491 491 ccsds_pn_full_255.(i) 492 492 (Char.code (Bytes.get seq i)) 493 493 done ··· 509 509 match Scc.Coding.Convolutional.decode conv_coded with 510 510 | Error e -> 511 511 Alcotest.fail 512 - (Printf.sprintf "Convolutional decode failed in pipeline: %s" e) 512 + (Fmt.str "Convolutional decode failed in pipeline: %s" e) 513 513 | Ok rs_decoded_cw -> ( 514 514 match Scc.Coding.Reed_solomon.decode rs_decoded_cw with 515 515 | Error e -> 516 - Alcotest.fail (Printf.sprintf "RS decode failed in pipeline: %s" e) 516 + Alcotest.fail (Fmt.str "RS decode failed in pipeline: %s" e) 517 517 | Ok recovered -> 518 518 Alcotest.(check string) 519 519 "pipeline RS+Conv roundtrip" (Bytes.to_string data)
+3 -3
test/test_sync.ml
··· 262 262 (fun (input, expected, label) -> 263 263 let data = Bytes.of_string input in 264 264 let parity = Char.code (Scc.Sync.Cltu.bch_parity data 0) in 265 - Alcotest.(check int) (Printf.sprintf "parity %s" label) expected parity) 265 + Alcotest.(check int) (Fmt.str "parity %s" label) expected parity) 266 266 cases 267 267 268 268 (* --- BCH single-bit error detection --- *) ··· 288 288 Bytes.set corrupted byte_pos (Char.chr (orig lxor (1 lsl bit_pos))); 289 289 let result = Scc.Sync.Cltu.bch_verify corrupted 0 parity in 290 290 Alcotest.(check bool) 291 - (Printf.sprintf "data bit %d.%d detected" byte_pos bit_pos) 291 + (Fmt.str "data bit %d.%d detected" byte_pos bit_pos) 292 292 false result 293 293 done 294 294 done ··· 308 308 Bytes.set corrupted 7 (Char.chr (orig lxor (1 lsl bit_pos))); 309 309 let result = Scc.Sync.Cltu.bch_verify corrupted 0 (Bytes.get corrupted 7) in 310 310 Alcotest.(check bool) 311 - (Printf.sprintf "parity bit %d detected" bit_pos) 311 + (Fmt.str "parity bit %d detected" bit_pos) 312 312 false result 313 313 done 314 314