-
Notifications
You must be signed in to change notification settings - Fork 61
Space Packet Protocol CCSDS
This section details the implementation of the core communication protocol used by FlatSat, which follows the standardized CCSDS Space Packet Protocol (SPP). This protocol allows the spacecraft to route data efficiently using Application Process Identifiers (APIDs), enabling modular subsystem addressing.
The Space Packet Protocol is the structural standard utilized for communication between the ground station and the satellite, as well as between different onboard subsystems. Every packet transmitted or received over the RF link (Radio 0 and Radio 1) or the USB link (usbCDC) wraps the data into a standard frame structure.
Every space packet processed by the system consists of a Primary Header (6 bytes) followed by a variable-length Data Field.
The structure of the packet is divided into the following fields based on the firmware's parsing logic:
- Version: Identifies the version of the Space Packet Protocol.
-
Type (1 bit): Defines the direction or purpose of the traffic.
-
0represents Telemetry (TM) (data leaving the satellite to the ground). -
1represents Telecommands (TC) (commands sent to the satellite).
-
- APID (11 bits): The Application Process Identifier used to route the traffic to the correct subsystem handler.
- Segmentation Flags: Defines whether the packet is unsegmented, part of a sequence (START/CONTINUE), or the end of a block.
- Sequence Count (14 bits): A sequential counter used to track and order incoming or outgoing packets.
- Data Length: Specifies the total length of the Data Field minus one.
The firmware filters and categorizes all incoming and outgoing traffic into specific Application Process Identifiers. The internal commandApidHandler matches the extracted APID to route execution to the appropriate subsystem:
| APID | Function | Traffic Type | Subsystem / Payload Description |
|---|---|---|---|
| 0x01 | PING | TC / TM | Connectivity heartbeat / Acknowledgement (ACK). |
| 0x02 | RESET | TC | Triggers a hardware watchdog reboot via softwareReset(). |
| 0x04 | THRUSTER | TC / TM | Set or Get power levels for thrusters T0/T1. |
| 0x06 | BROADCAST | TC | Broadcast messages handling (SPP_APID_TC_BROADCAST_MSG). |
| 0x07 | FLASH | TC / TM | Trigger fragmented image/firmware data transfer. |
| 0x08 | SEND_TM | TM | Standard periodic sensor telemetry frame transmission. |
When a packet arrives or is generated, the firmware operates as a non-blocking state machine governed by the telemetryRadioWorker.
- Data enters the system via Radio 0 or the USB CDC line.
- The
spp_unpack_packetroutine is invoked to validate the incoming CCSDS header. - The routine verifies version consistency, alignment, and checks the packet length against the received buffer size.
- If an error occurs during this phase, the system triggers a visual alert (8 yellow blinks on the NeoPixel LED) and aborts processing.
- If valid, the packet is sent to
commandApidHandlerto execute the subsystem action.
A practical implementation of the Space Packet Protocol's segmentation capability is found within the telemetrySPPTransmitFlash routine. This routine demonstrates how large blocks of data or firmware images are moved over a constrained link by utilizing packet sequencing:
- Fragmentation: The data block is split into sequential chunks of 16 bytes each.
-
Header Flags: Each chunk is packed into an individual SPP packet, where the primary header is updated with the respective segmentation tracking flags:
-
STARTfor the first packet of the block. -
CONTINUEfor intermediate data segments. -
ENDfor the final terminating chunk.
-
-
Integrity Validation: A custom
crc8_computeroutine is applied to each individual 16-byte chunk during transit to ensure that data does not suffer corruption over the RF link.
FlatSat Ecosystem v1.0.0 — Maintained by Pwnsat and Electronic Cats. For authorized educational and security research purposes only.