CCSDS USLP (Unified Space Link Protocol) Transfer Frame- unified TM/TC/AOS
OCaml 67.8%
C 25.3%
PHP 1.3%
Dune 1.2%
Roff 0.7%
Other 3.6%
22 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-uslp https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-uslp
git@git.recoil.org:gazagnaire.org/ocaml-uslp git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-uslp

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

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