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 headerTc.t- Complete TC frame
Functions#
Tc.decode- Parse TC frame from bytesTc.encode- Serialize TC frame to bytesTc.compute_fecf- Calculate CRC-16-CCITT
References#
- CCSDS 232.0-B-4 - TC Space Data Link Protocol specification
Licence#
MIT License. See LICENSE.md for details.