CCSDS TC Transfer Frames (CCSDS 232.0-B-4)
OCaml 62.9%
C 29.4%
PHP 1.5%
Dune 1.4%
Roff 0.7%
Other 4.1%
27 1 0

Clone this repository

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

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

Download tar.gz
README.md

tc#

CCSDS TC (Telecommand) Transfer Frames for OCaml.

Overview#

This library implements parsing and encoding of CCSDS TC Transfer Frames as specified in CCSDS 232.0-B-4. TC frames are the fundamental data unit for transporting commands from ground stations to spacecraft.

Features#

  • TC frame primary header (5 bytes) encoding/decoding
  • Bypass and control command flags for Type-A/Type-B distinction
  • Frame Error Control Field (FECF) using CRC-16-CCITT
  • Typed spacecraft ID (SCID) and virtual channel ID (VCID)
  • Security-hardened parsing with bounds checking

Installation#

opam install tc

Usage#

(* Create a TC frame *)
let scid = Tc.scid_exn 100 in
let vcid = Tc.vcid_exn 2 in
let data = String.make 50 '\x00' in
let frame = Tc.make ~scid ~vcid ~seq_num:1 ~bypass:true data in

(* Encode to bytes *)
let bytes = Tc.encode frame in

(* Decode from bytes *)
match Tc.decode bytes with
| Ok frame ->
    Printf.printf "SCID: %d, Bypass: %b\n"
      (Tc.scid_to_int frame.header.scid)
      frame.header.bypass
| Error e -> Format.printf "Error: %a\n" Tc.pp_error e

Frame Structure#

+----------------+-------------+------+
| Primary Header | Data Field  | FECF |
|   (5 bytes)    | (variable)  | (2B) |
+----------------+-------------+------+

The header contains:

  • Version (2 bits): Always 00 for TC
  • Bypass flag: Type-B for FARM bypass
  • Control command flag: Type-A/B distinction
  • Spacecraft ID (10 bits)
  • Virtual Channel ID (6 bits)
  • Frame length (10 bits): Total length - 1
  • Sequence number (8 bits)

API#

Types#

  • Tc.scid - Spacecraft ID (10 bits, 0-1023)
  • Tc.vcid - Virtual Channel ID (6 bits, 0-63)
  • Tc.header - TC frame primary header
  • Tc.t - Complete TC frame

Functions#

  • Tc.decode - Parse TC frame from bytes
  • Tc.encode - Serialize TC frame to bytes
  • Tc.compute_fecf - Calculate CRC-16-CCITT

References#

Licence#

MIT License. See LICENSE.md for details.