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.

chore: extract shared CRC to ocaml-crc and update dependencies

Replace inline CRC-16/32 implementations in aos, bundle, cfdp, pid1, tc,
tm, uslp with shared ocaml-crc dependency. Fix ocaml-crc test formatting.

+5 -49
+1
dune-project
··· 20 20 (depends 21 21 (ocaml (>= 4.14)) 22 22 (clcw (>= 0.1)) 23 + (crc (>= 0.1)) 23 24 (alcotest :with-test) 24 25 (crowbar :with-test)))
+1 -1
lib/dune
··· 1 1 (library 2 2 (name uslp) 3 3 (public_name uslp) 4 - (libraries clcw wire)) 4 + (libraries clcw crc wire))
+2 -48
lib/uslp.ml
··· 150 150 set_u8 b (off + i) (v lsr (8 * (len - 1 - i))) 151 151 done 152 152 153 - (* {1 CRC-16-CCITT} *) 154 - 155 - let crc16_ccitt_table = 156 - let table = Array.make 256 0 in 157 - for i = 0 to 255 do 158 - let crc = ref (i lsl 8) in 159 - for _ = 0 to 7 do 160 - if !crc land 0x8000 <> 0 then crc := (!crc lsl 1) lxor 0x1021 161 - else crc := !crc lsl 1 162 - done; 163 - table.(i) <- !crc land 0xFFFF 164 - done; 165 - table 166 - 167 - let compute_crc16 data = 168 - let crc = ref 0xFFFF in 169 - for i = 0 to String.length data - 1 do 170 - let byte = Char.code data.[i] in 171 - let idx = (!crc lsr 8) lxor byte land 0xFF in 172 - crc := (!crc lsl 8) lxor crc16_ccitt_table.(idx) land 0xFFFF 173 - done; 174 - !crc 175 - 176 - (* {1 CRC-32 (ISO 3309)} *) 177 - 178 - let crc32_table = 179 - let table = Array.make 256 0l in 180 - for i = 0 to 255 do 181 - let crc = ref (Int32.of_int i) in 182 - for _ = 0 to 7 do 183 - if Int32.logand !crc 1l <> 0l then 184 - crc := Int32.logxor (Int32.shift_right_logical !crc 1) 0xEDB88320l 185 - else crc := Int32.shift_right_logical !crc 1 186 - done; 187 - table.(i) <- !crc 188 - done; 189 - table 190 - 191 - let compute_crc32 data = 192 - let crc = ref 0xFFFFFFFFl in 193 - for i = 0 to String.length data - 1 do 194 - let byte = Char.code data.[i] in 195 - let idx = 196 - Int32.to_int (Int32.logand (Int32.logxor !crc (Int32.of_int byte)) 0xFFl) 197 - in 198 - crc := Int32.logxor (Int32.shift_right_logical !crc 8) crc32_table.(idx) 199 - done; 200 - Int32.to_int (Int32.logxor !crc 0xFFFFFFFFl) land 0xFFFFFFFF 153 + let compute_crc16 = Crc.crc16_ccitt 154 + let compute_crc32 = Crc.crc32 201 155 202 156 (* {1 Header decoding} *) 203 157
+1
uslp.opam
··· 12 12 "dune" {>= "3.21"} 13 13 "ocaml" {>= "4.14"} 14 14 "clcw" {>= "0.1"} 15 + "crc" {>= "0.1"} 15 16 "alcotest" {with-test} 16 17 "crowbar" {with-test} 17 18 "odoc" {with-doc}