Minimal, embedded-optimized implementation of the SpaceWire packet and network layers (ECSS-E-ST-50-12C) carrying the CCSDS Packet Transfer Protocol (ECSS-E-ST-50-53C).
Standards Compliance
ECSS-E-ST-50-12C Rev.1: SpaceWire — links, nodes, routers and networks
ECSS-E-ST-50-53C: SpaceWire — CCSDS packet transfer protocol
ECSS-E-ST-50-51C: SpaceWire — protocol identification (Protocol ID 0x02)
CCSDS 133.0-B-2: Space Packet Protocol
Features
Core Protocol Implementation
Network layer: SpaceWire packets and routing — path (0–31) and logical
(32–254) addressing with header deletion (ECSS-E-ST-50-12C §5.6)
CCSDS Packet Transfer Protocol: encapsulation/extraction of CCSDS Space
Packets with EOP/EEP receive status (ECSS-E-ST-50-53C)
CCSDS Integration: built on the EmbeddedSpacePacket library
Scope (hardware boundary)
This is a packet- and network-layer library. The character/signal and
data-link levels — character encoding and parity, data-strobe signalling, link
initialisation and flow control, and EOP/EEP generation and detection — are
provided by the SpaceWire hardware CODEC. EOP/EEP are exchanged with this
library as out-of-band metadata, not as bytes within packet buffers.
Design Principles
Minimal footprint: small static library, no dynamic allocation
Zero allocation: stack- and caller-owned buffers only
Embedded-optimized: no external dependencies except EmbeddedSpacePacket
Portable: pure C99, big-endian network byte order
Standards-driven: no non-standard framing or checksums on the wire
sw_router_t: ~1.4 KB — a 256-entry routing table (3 B/entry) plus per-port
link state; set -DSW_NUM_PORTS=n to shrink the per-router footprint
Thread Safety
Packet, routing and link operations work entirely on caller-owned state passed
by pointer and take no internal locks, so independent objects can be used from
independent tasks. The one shared item is the library’s statistics block:
sw_packet_encode and sw_packet_decode update a process-global counter (read
via sw_get_statistics, cleared via sw_reset_statistics), which is not
thread-safe. In a multi-task system, serialise the encode/decode/statistics
calls or confine them to a single task.
Limitations and Extensions
The library implements the packet and network layers; the following are out of
scope or not yet implemented:
Character/signal and data-link levels — provided by the SpaceWire hardware CODEC
Time-codes, broadcast codes and distributed interrupts (ECSS-E-ST-50-12C §5.6)
Group adaptive routing (one output port per logical address)
Guaranteed delivery — per ECSS-E-ST-50-53C the service is unconfirmed and
incomplete (no acknowledgement, retransmission or QoS)
These can be added as needed for specific mission requirements.
References
ECSS-E-ST-50-12C Rev.1 — SpaceWire: links, nodes, routers and networks
ECSS-E-ST-50-53C — SpaceWire: CCSDS packet transfer protocol
EmbeddedSpaceWire
Minimal, embedded-optimized implementation of the SpaceWire packet and network layers (ECSS-E-ST-50-12C) carrying the CCSDS Packet Transfer Protocol (ECSS-E-ST-50-53C).
Standards Compliance
0x02)Features
Core Protocol Implementation
Scope (hardware boundary)
This is a packet- and network-layer library. The character/signal and data-link levels — character encoding and parity, data-strobe signalling, link initialisation and flow control, and EOP/EEP generation and detection — are provided by the SpaceWire hardware CODEC. EOP/EEP are exchanged with this library as out-of-band metadata, not as bytes within packet buffers.
Design Principles
Project Structure
Building
Prerequisites
This repository vendors the CCSDS Space Packet library as a git submodule. After cloning, initialise it:
Build Everything
Build Library Only
Build Example
Run Tests
Test binary path:
build/bin/spacewire_tests.Coverage (HTML)
Coverage report is generated at
build/coverage/index.html.Clean
Quick Start
See examples/main.c.
Memory Usage
.text); no dynamic allocation, all buffers caller-ownedsw_packet_frame_t: 40 bytes (CCSDS PTP packet state)sw_router_t: ~1.4 KB — a 256-entry routing table (3 B/entry) plus per-port link state; set-DSW_NUM_PORTS=nto shrink the per-router footprintThread Safety
Packet, routing and link operations work entirely on caller-owned state passed by pointer and take no internal locks, so independent objects can be used from independent tasks. The one shared item is the library’s statistics block:
sw_packet_encodeandsw_packet_decodeupdate a process-global counter (read viasw_get_statistics, cleared viasw_reset_statistics), which is not thread-safe. In a multi-task system, serialise the encode/decode/statistics calls or confine them to a single task.Limitations and Extensions
The library implements the packet and network layers; the following are out of scope or not yet implemented:
These can be added as needed for specific mission requirements.
References
License
See LICENSE file.