- OCaml 88%
- Java 6%
- Python 4%
- Shell 2%
xtce #
XTCE telemetry and telecommand databases for OCaml: parse the XML, then decode binary packets with it.
A spacecraft's telemetry arrives as packed binary packets, and the meaning of
each bit lives in a database that the mission keeps next to the flight
software. XTCE (XML Telemetric
and Command Exchange, CCSDS 660.1-B-2, also an OMG standard) is the exchange
format for such databases: it describes the parameters, their encodings,
calibrations and alarm limits, and the containers that lay them out in a
packet. This library parses an XTCE document into typed OCaml values and
applies it to a packet: Xtce.extract picks the most specific container whose
restriction criteria the packet satisfies, reads each parameter, converts the
raw value to engineering units and checks it against its alarm ranges.
A sequence container lists the parameters of a packet in order with their bit widths. A container may extend a base container and add a restriction criterion, such as "APID = 100 and packet type = 3", so decoding walks from the generic packet header down to the most derived container whose conditions the fields decoded so far satisfy. A raw value, such as a 12-bit ADC count, becomes an engineering value, such as degrees Celsius, through its calibrator; here that is a polynomial a₀ + a₁x + a₂x² + ... of the raw value x (CCSDS 660.1-B-2, sections 3.4 and 3.6).
It implements a subset of the standard, listed below. An element it does not
implement is kept as an Unsupported_entry instead of being dropped, so a
database still loads even where a packet that uses the element cannot be laid
out. Commands (MetaCommand) are not parsed.
Installation #
$ opam install xtce
If opam cannot find the package, it has not reached the public
opam-repository yet. Add the overlay repository first:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install xtce
Usage #
let report xml_string =
let xtce = Xtce.of_string xml_string in
List.iter
(fun (param : Xtce.parameter) ->
Fmt.pr "Parameter: %s (type: %s)@." param.name param.parameter_type_ref)
xtce.Xtce.parameters
Xtce.of_string raises Failure on malformed XML or a missing required
element, and Xtce.extract raises Xtce.Extraction_error when a packet is too
short or a reference does not resolve; it never returns a partial decode.
Supported elements #
The library reads these elements of CCSDS 660.1-B-2:
| XTCE Element | Status |
|---|---|
| SpaceSystem | Supported |
| IntegerParameterType | Supported |
| FloatParameterType | Supported |
| EnumeratedParameterType | Supported |
| StringParameterType | Supported |
| BooleanParameterType | Supported |
| Parameter | Supported |
| SequenceContainer | Supported |
| PolynomialCalibrator | Supported |
| StaticAlarmRanges | Supported |
License #
ISC. See LICENSE.md.