ocaml-uslp#
CCSDS USLP (Unified Space Link Protocol) Transfer Frame parser and encoder.
USLP frames are defined in CCSDS 732.1-B-2 and unify TM, TC, and AOS protocols with additional features.
Installation#
opam install uslp
Usage#
(* Decode a USLP frame *)
let () =
let buf = (* ... frame bytes ... *) in
match Uslp.decode buf with
| Error e -> Printf.printf "Error: %a\n" Uslp.pp_error e
| Ok frame ->
Printf.printf "SCID: %d, VCID: %d, MAP: %d\n"
(Uslp.scid_to_int frame.header.scid)
(Uslp.vcid_to_int frame.header.vcid)
(Uslp.map_id_to_int frame.header.map_id)
(* Create and encode a USLP frame *)
let () =
let scid = Uslp.scid_exn 1000 in
let vcid = Uslp.vcid_exn 5 in
let map_id = Uslp.map_id_exn 3 in
let frame = Uslp.v ~scid ~vcid ~map_id ~vcfc:12345 ~vcfc_len:2 "payload" in
let encoded = Uslp.encode ~fecf:Uslp.Crc16 frame in
Printf.printf "Encoded: %d bytes\n" (String.length encoded)
(* Decode with VCFC and CRC-32 *)
let () =
let buf = (* ... *) in
match Uslp.decode ~vcfc_len:2 ~expect_fecf:Uslp.Crc32 buf with
| Error e -> Printf.printf "Error: %a\n" Uslp.pp_error e
| Ok frame -> Printf.printf "VCFC: %d\n" frame.header.vcfc
Frame Format#
Primary header (7+ bytes):
Byte 0: TFVN(4b) | SCID[15:12](4b)
Byte 1: SCID[11:4](8b)
Byte 2: SCID[3:0](4b) | src_dest(1b) | VCID[5:3](3b)
Byte 3: VCID[2:0](3b) | MAP_ID(4b) | EOFPH(1b)
Byte 4-5: Frame Length - 1 (16b)
Byte 6: Bypass(1b) | PCC(1b) | Rsvd(2b) | OCF(1b) | VCFC_len(3b)
Byte 7+: VCFC (0-7 bytes based on vcfc_len)
Optional insert zone (variable)
Data field (variable)
Optional OCF (4 bytes) - Contains CLCW
Optional FECF (2 or 4 bytes) - CRC-16-CCITT or CRC-32
Features#
- Variable-length VCFC (0-7 bytes)
- 16-bit SCID (vs 8-bit in AOS, 10-bit in TM)
- MAP IDs for multiplexed access points
- Source/Destination indicator
- CRC-16-CCITT or CRC-32 FECF
Licence#
MIT