My own corner of monopam
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

README.md

TCF -- CCSDS Time Code Formats (CUC and CDS)#

Pure OCaml implementation of CCSDS 301.0-B-4 time code formats:

  • CUC (CCSDS Unsegmented Code) -- Compact mission-configurable timestamps with 1-4 byte coarse time and 0-3 byte fine time
  • CDS (CCSDS Day Segmented) -- Day-based time: 2-byte day count + millisecond/microsecond of day

Uses bytesrw for streaming I/O.

Installation#

Install with opam:

$ opam install tcf

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 tcf

Usage#

(* CUC: encode/decode a timestamp. *)
let cuc_config = Tcf.Cuc.config_4_2

let cuc_bytes =
  Tcf.Cuc.encode cuc_config (Tcf.Cuc.of_parts ~coarse:1234567890L ~fine:32768)

let () =
  match Tcf.Cuc.decode cuc_config cuc_bytes with
  | Ok t -> Fmt.pr "%a@." Tcf.Cuc.pp t
  | Error `Truncated -> Fmt.epr "truncated@."

(* CDS: encode/decode a day-segmented time. *)
let cds_config = Tcf.Cds.config_2_0
let cds_value = Tcf.Cds.of_parts ~day:9131 ~ms:43200000 ~submilli:0
let cds_bytes = Tcf.Cds.encode cds_config cds_value

let () =
  match Tcf.Cds.decode cds_config cds_bytes with
  | Ok t -> Fmt.pr "%a@." Tcf.Cds.pp t
  | Error `Truncated -> Fmt.epr "truncated@."

Epoch Constants#

  • Tcf.tai_to_gps_offset -- TAI to GPS epoch offset
  • Tcf.tai_to_unix_offset -- TAI to Unix epoch offset
  • Tcf.tai_to_j2000_offset -- TAI to J2000 epoch offset

Duration Module#

Tcf.Duration provides nanosecond-precision duration conversions: of_ns, of_us, of_ms, of_sec and their to_* counterparts.

Reference#

Licence#

ISC