Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish to crates.io

on:
release:
types: [published]
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
publish:
name: crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Publish workspace crates in topological order
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "::notice::CARGO_REGISTRY_TOKEN is not set; skipping crates.io publish"
exit 0
fi
for crate in xtce-pus xtce-model xtce-decode xtce-codegen xtce-cli; do
echo "=== Publishing $crate ==="
if output=$(cargo publish -p "$crate" 2>&1); then
echo "$output"
sleep 10
else
echo "$output"
if echo "$output" | grep -qiE "already exists|already uploaded"; then
echo "::notice::$crate is already published at this version; continuing"
else
exit 1
fi
fi
done
56 changes: 56 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Python Wheels (PyPI)

on:
release:
types: [published]
push:
tags: ["v*"]
workflow_dispatch:

jobs:
build-wheels:
name: wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: Swatinem/rust-cache@v2
- name: Build Python wheel with maturin
run: |
pip install maturin
maturin build --release --out dist --manifest-path crates/xtce-py/Cargo.toml
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: dist/*.whl

publish-pypi:
name: publish to PyPI
needs: build-wheels
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Publish wheels to PyPI
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
if [ -z "$MATURIN_PYPI_TOKEN" ]; then
echo "::notice::PYPI_API_TOKEN is not set; wheels are built and uploaded as workflow artifacts"
exit 0
fi
pip install maturin
maturin upload dist/*.whl
17 changes: 11 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ members = ["crates/*", "xtask"]
exclude = ["crates/xtce-py"]

[workspace.package]
version = "0.1.1"
version = "0.2.1"
edition = "2024"
rust-version = "1.85"
license = "MIT OR Apache-2.0"
repository = "https://github.com/RustSpaceLab/xtce-rs"
authors = ["Maciej Myszkiewicz"]

[workspace.dependencies]
xtce-model = { path = "crates/xtce-model", version = "0.1.0" }
xtce-decode = { path = "crates/xtce-decode", version = "0.1.0" }
xtce-codegen = { path = "crates/xtce-codegen", version = "0.1.0" }
xtce-model = { path = "crates/xtce-model", version = "0.2.1" }
xtce-decode = { path = "crates/xtce-decode", version = "0.2.1" }
xtce-codegen = { path = "crates/xtce-codegen", version = "0.2.1" }
xtce-pus = { path = "crates/xtce-pus", version = "0.2.1" }

# Keep this list short and justified — see CONTRIBUTING.md rule 7.
anyhow = "1"
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# xtce-rs

[![CI](https://github.com/RustSpaceLab/xtce-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/RustSpaceLab/xtce-rs/actions/workflows/ci.yml)
[![crates.io](https://img.shields.io/crates/v/xtce-cli.svg)](https://crates.io/crates/xtce-cli)
[![docs.rs](https://docs.rs/xtce-decode/badge.svg)](https://docs.rs/xtce-decode)

Decode CCSDS telemetry packets in Rust, according to an [XTCE](https://www.omg.org/spec/XTCE/)
definition. Part of [RustSpaceLab](https://github.com/RustSpaceLab).

🛰️ **Live Interactive Mission Demo (OrbitTrack & ECSS PUS-C Telemetry Studio):**
👉 **[https://altanix.dev/mission-demo/](https://altanix.dev/mission-demo/)** — *Fly 5 live LEO satellites (`PIAST-M`, `CAMILA-1`, `EagleEye-2`, `PW-Sat3`, `OPS-SAT-2`) in 2D/3D orbit, uplink authenticated ECSS-E-ST-70-41C (PUS-C) telecommands over UDP to the `#![no_std]` OBC responder, inject orbital faults (`xtce sim`), and run `xtce diff` / `validate` / `codegen` / `wireshark` live in your browser.*

The reference implementation in this niche, [`lasp/space_packet_parser`][spp], has a known
performance problem: on real mission databases, loading the XTCE file costs more than parsing
the packets ([issue #112][issue112]). This project attacks both halves — a fast XML-to-IR
Expand All @@ -13,10 +18,11 @@ validated against that same implementation packet for packet.

| Crate | What it does |
|---|---|
| `xtce-model` | XTCE XML → arena-backed IR, reference resolution, validation; telemetry and telecommands |
| `xtce-decode` | IR + `&[u8]` → parameter values |
| `xtce-codegen` | IR → a static Rust decoder with every offset baked in |
| `xtce-cli` | `xtce info`, `xtce decode`, `xtce codegen`, `xtce bench` |
| [`xtce-model`](https://crates.io/crates/xtce-model) | XTCE XML → arena-backed IR, reference resolution, validation; telemetry and telecommands |
| [`xtce-decode`](https://crates.io/crates/xtce-decode) | IR + `&[u8]` / `PacketReader` → parameter values |
| [`xtce-codegen`](https://crates.io/crates/xtce-codegen) | IR → a static Rust decoder with every offset baked in |
| [`xtce-pus`](https://crates.io/crates/xtce-pus) | `#![no_std]` ECSS-E-ST-70-41C (PUS-C) framing, CRC-16-CCITT, and HIL OBC responder |
| [`xtce-cli`](https://crates.io/crates/xtce-cli) | `xtce info`, `xtce decode`, `xtce codegen`, `xtce compile`, `xtce wireshark`, `xtce pcap`, `xtce encode`, `xtce pus`, `xtce diff`, `xtce validate`, `xtce sim`, `xtce bench` |
| `xtce-py` | Python bindings (PyO3), built by `maturin` |
| `xtask` | differential test harness against the Python reference |

Expand Down Expand Up @@ -66,12 +72,18 @@ back — see [`SUPPORTED.md`](SUPPORTED.md).
#### Try it

```console
$ cargo install xtce-cli
$ cargo run --release -p xtce-cli -- info testdata/spp/ctim/ctim_xtce_v1.xml
$ cargo run --release -p xtce-cli -- decode \
testdata/spp/jpss/jpss1_geolocation_xtce_v1.xml \
testdata/spp/jpss/J01_G011_LZ_2021-04-09T00-00-00Z_V01.DAT1 --limit 3 --raw
$ cargo run --release -p xtce-cli -- codegen \
testdata/spp/jpss/jpss1_geolocation_xtce_v1.xml
$ cargo run --release -p xtce-cli -- wireshark \
testdata/spp/jpss/jpss1_geolocation_xtce_v1.xml --udp-port 5005
$ cargo run --release -p xtce-cli -- pcap \
testdata/spp/jpss/J01_G011_LZ_2021-04-09T00-00-00Z_V01.DAT1 --limit 10 -o jpss.pcap
$ cargo run --release -p xtce-cli -- pus --hil-demo
$ cargo xtask diff
$ cargo bench
```
Expand Down
1 change: 1 addition & 0 deletions crates/xtce-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ path = "src/main.rs"
xtce-model.workspace = true
xtce-decode.workspace = true
xtce-codegen.workspace = true
xtce-pus.workspace = true
clap.workspace = true
63 changes: 57 additions & 6 deletions crates/xtce-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,65 @@
# xtce-cli

The `xtce` command: inspect an XTCE definition and decode a CCSDS stream against it.
[![crates.io](https://img.shields.io/crates/v/xtce-cli.svg)](https://crates.io/crates/xtce-cli)

The `xtce` command-line tool: inspect XTCE definitions, stream-decode CCSDS telemetry, compile
static Rust decoders and Wireshark Lua dissectors, convert raw recordings to `.pcap`, and run
ECSS-E-ST-70-41C (PUS-C) Hardware-in-the-Loop (HIL) sessions.

## Installation

```console
$ xtce info mission.xml # what it contains, and what cannot be decoded
$ xtce decode mission.xml downlink.dat # values, as a table or as JSON lines
$ xtce decode mission.xml downlink.dat --param 'ADGPSPOS*'
$ cargo install xtce-cli
```

`--param` takes a glob, and a value matching nothing in the definition is an error naming the
nearest parameter rather than an empty report.
## Usage

```console
# 1. Inspect an XTCE definition (parameters, containers, telecommands)
$ xtce info mission.xml --verbose

# 2. Decode a CCSDS packet stream (from a file or '-' standard input) as a table, JSONL, or CSV
$ xtce decode mission.xml downlink.dat --format table
$ xtce decode mission.xml downlink.dat --format csv --raw > telemetry.csv
$ cat downlink.dat | xtce decode mission.xml - --param 'ADGPSPOS*' --no-summary

# 3. Compile an XTCE definition into a zero-allocation static Rust decoder
$ xtce codegen mission.xml -o decoder.rs

# 4. Generate a standalone Wireshark Lua dissector and wrap raw CCSDS frames in a .pcap file
$ xtce wireshark mission.xml --udp-port 5005 -o mission.lua
$ xtce pcap downlink.dat -o downlink.pcap
$ wireshark -X lua_script:mission.lua downlink.pcap

# 5. Assemble a binary CCSDS telemetry or telecommand packet from an XTCE definition
$ xtce encode ecss_pus.xml TM_3_25_ObcHousekeeping \
--set CCSDS_SEC_HDR=1 --set CCSDS_APID=0x010 --set PUS_VERSION=2 \
--set HK_SID=1 --set OBC_UPTIME_S=3600 --set OBC_MODE=EO_IMAGING --crc --hex

# 6. Inspect ECSS-E-ST-70-41C (PUS-C) frames, run a live UDP HIL OBC server, or emit XTCE XML
$ xtce pus --hil-demo -o hil_session.bin
$ xtce pus --hil-udp 127.0.0.1:5006
$ xtce pus --emit-xtce -o ecss_pus.xml
$ xtce decode ecss_pus.xml hil_session.bin --format table

# 7. Validate an XTCE definition or export a normalized JSON metadata dictionary
$ xtce validate ecss_pus.xml --strict
$ xtce validate ecss_pus.xml --json > metadata.json

# 8. Compare two XTCE definitions and classify changes (BREAKING, WARNING, COMPATIBLE)
$ xtce diff mission_v1.xml mission_v2.xml --fail-on-breaking

# 9. Simulate a deterministic CCSDS / ECSS PUS-C telemetry stream (with fault injection)
$ xtce sim --scenario voltage-drop --packets 20 --seed 42 -o fault_pass.bin
$ xtce sim --scenario overheat --packets 20 --seed 42 --pcap -o overheat_pass.pcap
$ xtce sim --scenario attitude-loss --packets 20 --seed 42 -o adcs_tumble.bin

# 10. Multi-target XTCE mission compiler (rust-ground, wireshark, json-schema, docs, dashboard)
$ xtce compile ecss_pus.xml --target rust-ground -o decoder.rs
$ xtce compile ecss_pus.xml --target wireshark -o mission.lua
$ xtce compile ecss_pus.xml --target json-schema -o mission.schema.json
$ xtce compile ecss_pus.xml --target docs -o MISSION_DICTIONARY.md
$ xtce compile ecss_pus.xml --target dashboard -o telemetry_studio.json
```

Part of [RustSpaceLab/xtce-rs](https://github.com/RustSpaceLab/xtce-rs).
Loading
Loading