Minimal, embedded-optimized implementation of CCSDS Space Data Link Protocol (SDLP) for TM (Telemetry) and TC (Telecommand) frame handling, following international standards.
- CCSDS 132.0-B-3: TM Space Data Link Protocol
- CCSDS 232.0-B-4: TC Space Data Link Protocol
- Telemetry (TM) Frame Handling: Create, encode, and decode TM frames
- Telecommand (TC) Frame Handling: Create, encode, and decode TC frames
- Frame Error Control Field (FECF): 2-byte FECF carried verbatim in the wire format; computing/validating the value (e.g. CRC-16) is left to the application
- Configurable: Support for virtual channels, spacecraft IDs, and frame sequence numbers
- TM Secondary Header: Optional Transfer Frame Secondary Header (1–63 data octets) via
sdlp_tm_set_secondary_header, signaled by the Secondary Header Flag and parsed automatically on decode - TM Operational Control Field: Optional 4-octet OCF carried verbatim via
sdlp_tm_set_ocf(the caller decides whether to set the OCF Flag); its content, e.g. a CLCW, is mission-specific and left to the application - TC Frame Types: Type-AD/BD/BC frames via
sdlp_tc_set_frame_type, plus Unlock and Set V(R) control-command helpers (sdlp_tc_create_unlock_frame,sdlp_tc_create_set_vr_frame) - TC Segment Header: Optional MAP-based segmentation support (enabled with
SDLP_TC_SEGMENT_HEADER_ENABLED)
- Minimal footprint: Small library size (stripped)
- Zero allocation: Stack-based, no dynamic memory
- Embedded-optimized: Pure C99, no external dependencies
- Portable: Standard C99, big-endian network byte order
EmbeddedSDLP/
├── .github/
│ └── workflows/
│ └── ci.yml # CI: unit tests, coverage gate, sanitizers
├── include/
│ ├── sdlp_common.h # Common definitions and error codes
│ ├── sdlp_tm.h # TM frame definitions
│ └── sdlp_tc.h # TC frame definitions
├── src/
│ ├── sdlp_tm.c # TM frame implementation
│ └── sdlp_tc.c # TC frame implementation
├── examples/
│ ├── example_crc.h # CRC-16 helper used only by the examples
│ ├── tm_example.c # TM frame example
│ └── tc_example.c # TC frame example
├── tests/
│ ├── cunit.h # Minimal unit-test assertion helpers
│ ├── test_runners.h # Per-module test runner interface
│ ├── test_tm.c # TM unit tests
│ ├── test_tc.c # TC unit tests
│ └── unit_tests.c # Test entry point (aggregates per-module results)
├── tools/
│ └── coverage_html.sh # Coverage (HTML) report generator
├── Makefile
└── README.md
Warnings are treated as errors (-Werror). The build is checked with both gcc and
clang; select the compiler with make CC=clang.
make allThis will create:
build/libsdlp.a- Static librarybuild/bin/tm_example- TM frame examplebuild/bin/tc_example- TC frame examplebuild/segment_header/tm_exampleandbuild/segment_header/tc_example- the same examples built with the optional TC Segment Header (SDLP_TC_SEGMENT_HEADER_ENABLED)
make lib
# Produces: build/libsdlp.a (static)make examples # build only
make example # build, then run tm_example and tc_examplemake testThe unit tests are built and run twice: against the library as make lib builds it, and
again with the optional TC Segment Header compiled in (SDLP_TC_SEGMENT_HEADER_ENABLED).
Requires gcovr installed in your system:
sudo apt install gcovrGenerate coverage report:
make coverage-htmlThe command fails unless line and branch coverage of src/ are both 100% in each of the
two build configurations (without and with the TC Segment Header). It rebuilds the unit
tests from scratch with the Makefile's own flags plus coverage instrumentation.
Output report:
build/coverage/index.html
make sanitize # rebuild with ASan + UBSan, run tests and examples, then clean upThe target starts from a clean build and removes build/ again when it finishes, so a
coverage report generated earlier is deleted with it.
make clean # Remove build artifactsLook at the examples/
- Library (stripped): < 5 KB
- Per TM frame buffer:
SDLP_TM_PRIMARY_HEADER_SIZE(6) + optional secondary header (≤ 64) + data + optional OCF (4) + 2 bytes FECF - Per TC frame buffer:
SDLP_TC_PRIMARY_HEADER_SIZE(5) + optional segment header (1) + data + 2 bytes FECF - Maximum data per frame:
SDLP_TM_MAX_DATA_SIZE= 1024 bytes (TM);SDLP_TC_MAX_DATA_SIZE= 1017 bytes (TC — the whole frame is capped at 1024 octets per CCSDS 232.0-B-4; one less when the TC segment header is enabled)
Current implementation focuses on core protocol features:
- No automatic retransmission handling (COP-1 FOP/FARM)
- No flow control or bandwidth management
- No segmentation beyond optional TC segment header
- No SDLS (Space Data Link Security) option
- No TM Only-Idle-Data (OID) frame generation or PN randomization
- TM Transfer Frames are variable length; the mission-fixed frame length must be enforced by the caller
- The 2-octet FECF is always emitted, although both standards make it optional
- The TC Segment Header is a build-time switch for all Virtual Channels, not per Virtual Channel; it changes
sdlp_tc_frame_t, so build the library and the application with the same setting - Decoders do not check the Transfer Frame Version Number
- TM frame counts are kept per Master Channel / Virtual Channel in fixed static state (not thread-safe). At most
SDLP_TM_MAX_MASTER_CHANNELS(default 8) Spacecraft IDs are tracked;sdlp_tm_create_framereturnsSDLP_ERROR_NO_RESOURCEfor one more, andsdlp_tm_reset_frame_countsempties the table
These can be extended as needed for specific mission requirements.
Apache License 2.0 - See LICENSE file for details.