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#
Install with opam:
$ opam install uslp
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install uslp
Usage#
(* Decode a USLP frame. *)
let decode_frame buf =
match Uslp.decode buf with
| Error e -> Fmt.epr "Error: %a@." Uslp.pp_error e
| Ok frame ->
Fmt.pr "SCID: %d, VCID: %d, MAP: %d@."
(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 encode_frame () =
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
Fmt.pr "Encoded: %d bytes@." (String.length encoded)
(* Decode with VCFC and CRC-32. *)
let decode_with_crc32 buf =
match Uslp.decode ~vcfc_len:2 ~expect_fecf:Uslp.Crc32 buf with
| Error e -> Fmt.epr "Error: %a@." Uslp.pp_error e
| Ok frame -> Fmt.pr "VCFC: %d@." 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