CRC checksums (CRC-16, CRC-32, CRC-32C) for OCaml
0
fork

Configure Feed

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

Split ocaml-transport into ocaml-cltu and ocaml-cop1

- ocaml-cltu: CLTU encoding/decoding (CCSDS 231.0-B) with BCH(63,56),
ASM sync markers (131.0-B), and stream sync parsers
- ocaml-cop1: COP-1 state machines (CCSDS 232.1-B) for FOP-1 (ground)
and FARM-1 (flight) with Eio service layer
- cltu-eio: CLTU/ASM send/recv over Eio flows
- cop1-eio: COP-1 service layer with Eio timer management

+12 -8
+12 -8
lib/crc.ml
··· 34 34 (* {1 CRC-16-X.25} 35 35 36 36 Polynomial: 0x8408 (reflected form of 0x1021) 37 - Init: 0xFFFF, reflected in/out, XOR out: 0xFFFF. 38 - Bit-at-a-time reflected algorithm (fast enough for small frames). *) 37 + Init: 0xFFFF, reflected in/out, XOR out: 0xFFFF. *) 38 + 39 + let crc16_x25_table = 40 + Array.init 256 (fun i -> 41 + let crc = ref i in 42 + for _ = 0 to 7 do 43 + if !crc land 1 <> 0 then crc := (!crc lsr 1) lxor 0x8408 44 + else crc := !crc lsr 1 45 + done; 46 + !crc) 39 47 40 48 let crc16_x25 data = 41 49 let crc = ref 0xFFFF in 42 50 for i = 0 to String.length data - 1 do 43 51 let byte = Char.code (String.unsafe_get data i) in 44 - for j = 0 to 7 do 45 - let bit = (byte lsr j) land 1 in 46 - let c0 = !crc land 1 in 47 - crc := !crc lsr 1; 48 - if bit lxor c0 = 1 then crc := !crc lxor 0x8408 49 - done 52 + let idx = !crc lxor byte land 0xFF in 53 + crc := (!crc lsr 8) lxor crc16_x25_table.(idx) 50 54 done; 51 55 !crc lxor 0xFFFF 52 56