Skip to main content

Various CCSDS and ECSS packet implementations

Project description

package Documentation Status codecov PyPI version

ECSS and CCSDS Spacepackets

This package contains generic implementations for various CCSDS (Consultative Committee for Space Data Systems) and ECSS (European Cooperation for Space Standardization) packet standards.

Currently, this includes the following components:

Install

You can install this package from PyPI

Linux:

python3 -m pip install spacepackets

Windows:

py -m pip install spacepackets

Examples

You can find all examples listed here in the example folder as well.

ECSS PUS Packets

This examples shows how to generate PUS packets using the PUS ping telecommand and a PUS ping telemetry reply:

from spacepackets.ecss.tc import PusTelecommand
from spacepackets.ecss.tm import PusTelemetry
from spacepackets.util import get_printable_data_string, PrintFormats


def main():
    print("-- PUS packet examples --")
    ping_cmd = PusTelecommand(service=17, subservice=1, apid=0x01)
    cmd_as_bytes = ping_cmd.pack()
    print_string = get_printable_data_string(
        print_format=PrintFormats.HEX, data=cmd_as_bytes
    )
    print(f"Ping telecommand [17,1]: {print_string}")

    ping_reply = PusTelemetry(service=17, subservice=2, apid=0x01)
    tm_as_bytes = ping_reply.pack()
    print_string = get_printable_data_string(
        print_format=PrintFormats.HEX, data=tm_as_bytes
    )
    print(f"Ping reply [17,2]: {print_string}")


if __name__ == "__main__":
    main()

CCSDS Space Packet

This example shows how to generate a space packet header:

from spacepackets.ccsds.spacepacket import SpacePacketHeader, PacketTypes
from spacepackets.util import get_printable_data_string, PrintFormats


def main():
    print("-- Space Packet examples --")
    spacepacket_header = SpacePacketHeader(
        packet_type=PacketTypes.TC, apid=0x01, source_sequence_count=0, data_length=0
    )
    header_as_bytes = spacepacket_header.pack()
    print_string = get_printable_data_string(
        print_format=PrintFormats.HEX, data=header_as_bytes
    )
    print(f"Space packet header: {print_string}")


if __name__ == "__main__":
    main()

USLP Frames

This example shows how to generate a simple variable length USLP frame containing a simple space packet:

from spacepackets.uslp.header import (
    PrimaryHeader,
    SourceOrDestField,
    ProtocolCommandFlag,
    BypassSequenceControlFlag,
)
from spacepackets.uslp.frame import (
    TransferFrame,
    TransferFrameDataField,
    TfdzConstructionRules,
    UslpProtocolIdentifier,
)
from spacepackets.ccsds.spacepacket import SpacePacketHeader, PacketTypes, SequenceFlags

SPACECRAFT_ID = 0x73


def main():
    print("-- USLP frame example --")
    frame_header = PrimaryHeader(
        scid=SPACECRAFT_ID,
        map_id=0,
        vcid=1,
        src_dest=SourceOrDestField.SOURCE,
        frame_len=0,
        vcf_count_len=0,
        op_ctrl_flag=False,
        prot_ctrl_cmd_flag=ProtocolCommandFlag.USER_DATA,
        bypass_seq_ctrl_flag=BypassSequenceControlFlag.SEQ_CTRLD_QOS,
    )
    data = bytearray([1, 2, 3, 4])
    # Wrap the data into a space packet
    space_packet_wrapper = SpacePacketHeader(
        packet_type=PacketTypes.TC,
        sequence_flags=SequenceFlags.UNSEGMENTED,
        apid=SPACECRAFT_ID,
        data_length=len(data) - 1,
        source_sequence_count=0,
    )
    tfdz = space_packet_wrapper.pack() + data
    tfdf = TransferFrameDataField(
        tfdz_cnstr_rules=TfdzConstructionRules.VpNoSegmentation,
        uslp_ident=UslpProtocolIdentifier.SPACE_PACKETS_ENCAPSULATION_PACKETS,
        tfdz=tfdz,
    )
    var_frame = TransferFrame(header=frame_header, tfdf=tfdf)
    var_frame_packed = var_frame.pack()
    print(
        f"USLP variable length frame without FECF, and Operation Control Field containing a "
        f"simple space packet: {var_frame_packed.hex(sep=',')}"
    )


if __name__ == "__main__":
    main()

Tests

All tests are provided in the tests folder and can be run with coverage information by running

coverage run -m pytest

provided that pytest and coverage were installed with

python3 -m pip install coverage pytest

License

Copyright 2019-2021 Robin Mueller, Institute of Space Systems Stuttgart, KSat e.V. Stuttgart

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spacepackets-0.8.0.tar.gz (60.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spacepackets-0.8.0-py3-none-any.whl (77.6 kB view details)

Uploaded Python 3

File details

Details for the file spacepackets-0.8.0.tar.gz.

File metadata

  • Download URL: spacepackets-0.8.0.tar.gz
  • Upload date:
  • Size: 60.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for spacepackets-0.8.0.tar.gz
Algorithm Hash digest
SHA256 42ee76da7fe360b3979c86949f72538860b9f8e92a8178d2b88f135bc2ea8e7c
MD5 70f43ece56e8d01fbd34d2d74ca1d44d
BLAKE2b-256 a693b53fc9f31ead771bc20659406a7f968bb5e2e9867778c9c6f33d639c9107

See more details on using hashes here.

File details

Details for the file spacepackets-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: spacepackets-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 77.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for spacepackets-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfde274e9110ba760d90d556b582b9db9f34e71856d5f1da04af5d15a8647e3d
MD5 e17e6d1bdfc1d5495723a7edebfd83fd
BLAKE2b-256 29a06dc7b99204fdc4ad598f5ae857debb330fa9e7ccc1f9a7d4d1219395020a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page