CCSDS TM Transfer Frames (CCSDS 132.0-B-3)
OCaml 70.2%
C 23.4%
PHP 1.2%
Dune 1.2%
Roff 0.7%
Other 3.4%
28 1 0

Clone this repository

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

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

Download tar.gz
README.md

tm#

CCSDS TM (Telemetry) Transfer Frames for OCaml.

Overview#

This library implements parsing and encoding of CCSDS TM Transfer Frames as specified in CCSDS 132.0-B-3. TM frames are the fundamental data unit for transporting telemetry from spacecraft to ground stations.

Features#

  • TM frame primary header (6 bytes) encoding/decoding
  • Operational Control Field (OCF) with CLCW support
  • Frame Error Control Field (FECF) using CRC-16-CCITT
  • Command Link Control Word (CLCW) for COP-1 protocol
  • Typed spacecraft ID (SCID) and virtual channel ID (VCID)
  • Security-hardened parsing with bounds checking

Installation#

opam install tm

Usage#

(* Create a TM frame *)
let scid = Tm.scid_exn 100 in
let vcid = Tm.vcid_exn 2 in
let data = String.make 1103 '\x00' in
let frame = Tm.make ~scid ~vcid ~mcfc:1 ~vcfc:2 data in

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

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

Working with CLCW#

(* Extract CLCW from frame OCF *)
match Tm.get_clcw frame with
| Ok clcw ->
    Printf.printf "Report value (N(R)): %d\n" clcw.report_value;
    if clcw.flags.lockout then print_endline "FARM-1 in lockout!"
| Error `No_ocf -> print_endline "No OCF present"
| Error (`Invalid_vcid _) -> print_endline "Invalid VCID in CLCW"

(* Create a CLCW *)
let clcw = Tm.make_clcw ~vcid ~report_value:42 ~lockout:false () in
let ocf_word = Tm.encode_clcw clcw in

Frame Structure#

+----------------+-------------+------+------+
| Primary Header | Data Field  | OCF  | FECF |
|   (6 bytes)    | (variable)  | (4B) | (2B) |
+----------------+-------------+------+------+

Standard CCSDS frame length is 1115 bytes (configurable).

API#

Types#

  • Tm.scid - Spacecraft ID (10 bits, 0-1023)
  • Tm.vcid - Virtual Channel ID (3 bits, 0-7)
  • Tm.header - TM frame primary header
  • Tm.clcw - Command Link Control Word
  • Tm.t - Complete TM frame

Functions#

  • Tm.decode - Parse TM frame from bytes
  • Tm.encode - Serialize TM frame to bytes
  • Tm.compute_fecf - Calculate CRC-16-CCITT
  • Tm.get_clcw - Extract CLCW from frame OCF

References#

Licence#

MIT License. See LICENSE.md for details.