spac_kit.generator

The generator module provides tools for creating simulated CCSDS packets for testing and development.

spac_kit.generator

Packet generator module for creating CCSDS packets from definitions.

class spac_kit.generator.PacketGenerator(packet: _BasePacket)

Bases: object

Generate CCSDS packets from packet definitions.

__init__(packet: _BasePacket)

Initialize the generator with a packet definition.

Parameters:

packet – A CCSDSpy packet definition (FixedLength or VariableLength)

write_packet(file_obj: BinaryIO, count: int = 1, use_random: bool = True)

Write one or more packets to a file using ccsdspy’s encoder.

Parameters:
  • file_obj – Binary file object to write to

  • count – Number of packets to write (default: 1)

  • use_random – If True, generate random data; if False, use zeros (default: True)

Note

Sequence count starts from 0 and increments automatically.

spac_kit.generator.generate_packets_from_definitions(packets: list, output_path: str)

Generate packets from a list of packet definitions and write to file.

Parameters:
  • packets – List of CCSDSpy packet definitions

  • output_path – Path to output binary file

spac_kit.generator.packet_generator

Generate CCSDS packets with zero/blank values from packet definitions.

class spac_kit.generator.packet_generator.PacketGenerator(packet: _BasePacket)

Bases: object

Generate CCSDS packets from packet definitions.

__init__(packet: _BasePacket)

Initialize the generator with a packet definition.

Parameters:

packet – A CCSDSpy packet definition (FixedLength or VariableLength)

write_packet(file_obj: BinaryIO, count: int = 1, use_random: bool = True)

Write one or more packets to a file using ccsdspy’s encoder.

Parameters:
  • file_obj – Binary file object to write to

  • count – Number of packets to write (default: 1)

  • use_random – If True, generate random data; if False, use zeros (default: True)

Note

Sequence count starts from 0 and increments automatically.

spac_kit.generator.packet_generator.generate_packets_from_definitions(packets: list, output_path: str)

Generate packets from a list of packet definitions and write to file.

Parameters:
  • packets – List of CCSDSpy packet definitions

  • output_path – Path to output binary file

spac_kit.generator.cli

Command-line interface for packet generation.

spac_kit.generator.cli.calculate_chi_squared(data: bytes) tuple[float, float]

Perform chi-squared test for uniform byte distribution.

Parameters:

data – Binary data to analyze

Returns:

Tuple of (chi_squared_statistic, p_value) p_value > 0.05 suggests data looks uniformly distributed

spac_kit.generator.cli.calculate_shannon_entropy(data: bytes) float

Calculate Shannon entropy of binary data in bits per byte.

Parameters:

data – Binary data to analyze

Returns:

Entropy value from 0.0 (all same byte) to 8.0 (perfectly random)

spac_kit.generator.cli.main()

Main entry point for packet generator CLI.