Skip to main content

Cubsat Space Protocol (CSP) native Python implementation

Project description

PyPI - Version GitHub Actions Workflow Status

CSP.py

Native Python, async-friendly implementation of Cubesat Space Protocol.

Features

  • Python friendly async API
  • Sockets and connections
  • Interfaces
  • Socket options
  • CIDR Routing table
  • Hooks for inspecting and/or modifying packets going through node
  • System services
    • Ping

Missing features compared to libcsp

  • RDP
  • Packet flags
    • HMAC
  • Remaining system sevices: uptime, reboot/shutdown, process list, memory free query, CSP Management Protocol
  • Simple fragmentation protocol

When to use over libcsp?

  • Easy use (pure Python library, no native dependencies)
  • Testing
    • csp-py allows to start and tear down entire node within single test without leaking anything between tests
  • Async API
    • Use asyncio to run communication, with gracefully handled timeouts and cancellations

Usage

  1. Install package using pip
    user$ pip install cubesat-space-protocol-py
    
  2. Create node:
    import csp_py
    
    node = csp_py.CspNode()
    
  3. Add interface
    from csp_py.interfaces.serializing_interface import CspSerializingInterface
    
    async def capture_frame(frame: bytes) -> None:
        # TODO: frame contains entire serialized packet including header
        # send it over some communication channel
        pass
    
    async def handle_incoming_frames(iface: CspSerializingInterface) -> None:
        while True:
            # TODO: fetch frame from communication channel
            frame: bytes = await recv_frame()
            await iface.on_incoming_frame(frame)
    
    iface = CspSerializingInterface(capture_frame)
    # TODO: make sure addresses are correct
    node.router.add_interface(iface, address=1, netmask_bits=10)
    asyncio.create_task(handle_incoming_frames(iface))
    
  4. Start router task
    router_task = asyncio.create_task(node.router.arun())
    
  5. Use sockets
    connection = await node.connect(dst=0, port=20)
    await connection.send(b'Hello, world!')
    response = await connection.recv()
    print(f'Got response: {response.data}')
    
  6. Stop router
    router_task.cancel()
    await router_task
    

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

cubesat_space_protocol_py-1.4.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

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

cubesat_space_protocol_py-1.4.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file cubesat_space_protocol_py-1.4.0.tar.gz.

File metadata

File hashes

Hashes for cubesat_space_protocol_py-1.4.0.tar.gz
Algorithm Hash digest
SHA256 ead14173f077f7dc6ec83b5ad4c7bc19cb2f68a04de7b17cf30fa5a948714c70
MD5 d9b8c0016d445206eeb1a37b749b65a9
BLAKE2b-256 0b906b99633f1a1d52929e0ce4f7e6004678ef03c2c1b8ed32d71ecdae5eae16

See more details on using hashes here.

Provenance

The following attestation bundles were made for cubesat_space_protocol_py-1.4.0.tar.gz:

Publisher: publish.yml on kplabs-pl/csp-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cubesat_space_protocol_py-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cubesat_space_protocol_py-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e41172dfa806ecd1dde28995646f090a1ae0796e575f976a52a5ed52ae3a00e
MD5 82e7b74f59825a90fec99dd7549a193c
BLAKE2b-256 f393fa8eb900ae37e922ca083eb6ab7b986ab83ca13c8bded6921222bdcfb88d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cubesat_space_protocol_py-1.4.0-py3-none-any.whl:

Publisher: publish.yml on kplabs-pl/csp-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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