Go implementation of the CCSDS 124.0-B-1 lossless compression algorithm of fixed-length housekeeping data.
If CCSDS 124.0-B-1 contributes to your research, please cite:
D. Evans, G. Labrèche, D. Marszk, S. Bammens, M. Hernandez-Cabronero, V. Zelenevskiy, V. Shiradhonkar, M. Starcik, and M. Henkel. 2022. "Implementing the New CCSDS Housekeeping Data Compression Standard 124.0-B-1 (based on POCKET+) on OPS-SAT-1," Proceedings of the Small Satellite Conference, Communications, SSC22-XII-03. https://digitalcommons.usu.edu/smallsat/2022/all2022/133/
@inproceedings{evans2022ccsds124,
author = {Evans, David and Labreche, Georges and Marszk, Dominik and Bammens, Samuel and Hernandez-Cabronero, Miguel and Zelenevskiy, Vladimir and Shiradhonkar, Vasundhara and Starcik, Mario and Henkel, Maximilian},
title = {Implementing the New CCSDS Housekeeping Data Compression Standard 124.0-B-1 (based on POCKET+) on OPS-SAT-1},
booktitle = {Proceedings of the Small Satellite Conference},
year = {2022},
note = {SSC22-XII-03},
url = {https://digitalcommons.usu.edu/smallsat/2022/all2022/133/}
}
Package ccsds124 implements the CCSDS 124.0-B-1 lossless data compression algorithm for fixed-length housekeeping data.
type Compressor struct {
// Contains filtered or unexported fields
}
Compressor maintains state for CCSDS 124.0-B-1 compression across multiple packets.
NewCompressor creates a new compressor with the given parameters. F is the input vector length in bits, initialMask is the optional initial mask, robustness is Rt (0-7), and ptLimit/ftLimit/rtLimit control automatic mode triggers.
CompressPacket compresses a single input packet and returns the compressed output.
Reset resets the compressor to its initial state.
type Decompressor struct {
F int // Input vector length in bits
// Contains filtered or unexported fields
}
Decompressor maintains state for CCSDS 124.0-B-1 decompression.
NewDecompressor creates a new decompressor with the given parameters.
DecompressPacket decompresses a single compressed packet.
DecompressStream decompresses multiple packets from a byte stream.
NewPacketIterator creates a streaming packet iterator for memory-efficient decompression.
StreamPackets returns a channel that yields decompressed packets.
type BitVector struct {
// Contains filtered or unexported fields
}
BitVector represents a fixed-length sequence of bits stored in 32-bit words with MSB-first bit ordering.
NewBitVector creates a new BitVector with the specified length in bits.
NewBitVectorFromBytes creates a BitVector from a byte slice.
GetBit returns the bit value (0 or 1) at the given position.
SetBit sets the bit at the given position to the specified value.
XOR returns a new BitVector that is the XOR of this and other.
OR returns a new BitVector that is the OR of this and other.
AND returns a new BitVector that is the AND of this and other.
NOT returns a new BitVector with all bits inverted.
HammingWeight returns the number of '1' bits in the vector.
ToBytes converts the BitVector to a byte slice.
type BitBuffer struct {
// Contains filtered or unexported fields
}
BitBuffer is a variable-length bit buffer for building compressed output.
NewBitBuffer creates a new BitBuffer with the specified initial capacity.
AppendBit appends a single bit (0 or 1) to the buffer.
AppendBits appends multiple bits from a value (MSB first).
Size returns the number of bits in the buffer.
ToBytes returns the buffer contents as a byte slice.
type BitReader struct {
// Contains filtered or unexported fields
}
BitReader provides sequential bit reading from a byte buffer.
NewBitReader creates a new BitReader from a byte slice.
NewBitReaderWithBits creates a BitReader with an explicit bit count.
ReadBit reads and returns the next bit.
ReadBits reads and returns the next count bits as a uint64.
Remaining returns the number of unread bits.
type Params struct {
NewMaskFlag bool // Force new mask transmission
ResetFlag bool // Force full packet transmission
}
Params contains per-packet compression parameters.
type PacketIterator struct {
// Contains filtered or unexported fields
}
PacketIterator provides streaming decompression with an iterator pattern.
Next returns the next decompressed packet, or nil if done or on error.
Err returns any error encountered during iteration.
CountEncode implements CCSDS 124.0-B-1 Section 5.2.2, Table 5-1, Equation 9. Encodes positive integers 1 <= A <= 2^16 - 1.
CountEncodeTerminator writes the RLE terminator pattern '10'.
RLEEncode implements CCSDS 124.0-B-1 Section 5.2.3, Equation 10. Encodes a bit vector using run-length encoding.
BitExtract implements CCSDS 124.0-B-1 Section 5.2.4, Equation 11. Extracts bits from data at positions where mask has '1' bits.
BitExtractForward extracts bits in forward order (lowest position to highest). Used for kt component.
CountDecode decodes a COUNT-encoded value. Returns the decoded positive integer.
RLEDecode decodes an RLE-encoded bit vector of the specified length.
BitInsert inserts bits from reader into data at positions where mask has '1' bits.
BitInsertForward inserts bits in forward order (for kt component).
UpdateBuild computes B_t = B_{t-1} OR D_t (CCSDS Equation 6).
UpdateMask computes M_t based on CCSDS Equation 7.
ComputeChange computes D_t = M_{t-1} XOR M_t (CCSDS Equation 8).
HorizontalXOR computes horizontal XOR for mask transmission: result[i] = input[i] XOR input[i+1].
const (
MaxRobustness = 7 // Maximum robustness parameter (R_t)
)
MaxRobustness defines the maximum allowed robustness parameter value per CCSDS 124.0-B-1.
Generated on 2026-06-29 15:01:43 UTC