Skip to main content

LwPKT (Python)

Pure-Python encoder/decoder for the LwPKT lightweight packet protocol, mirroring the reference C implementation. Read the full protocol documentation at docs.majerle.eu/projects/lwpkt.

Install

pip install lwpkt

Usage

from lwpkt import LwPKT, LwPKTError

pkt = LwPKT()
pkt.our_addr = 0x01

# Encode an outgoing packet
data = pkt.generate_packet(b"hello", cmd=0x02, addr_to=0x02)

# Feed received bytes in and process them
pkt.write_rx_data(data)
try:
    if pkt.rx_process():
        received = pkt.rx_get_packet()
        print(received.data, received.cmd, received.pkt_from)
except LwPKTError as e:
    print("Malformed packet, discarded:", e)

rx_process() raises a typed exception (LwPKTLengthError, LwPKTFieldOverflowError, LwPKTCRCError, LwPKTStopByteError - all subclasses of LwPKTError) when it encounters malformed input. The parser resets itself before raising, so it's always safe to keep calling write_rx_data() / rx_process() after catching one.

License

MIT, see LICENSE.

Metadata

Release files for lwpkt 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lwpkt 2.0.0
File Size Uploaded
lwpkt-2.0.0.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lwpkt 2.0.0
File Interpreter ABI Platform
lwpkt-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / lwpkt-2.0.0.tar.gz

Download URL lwpkt-2.0.0.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ba95faf61e052d3804f47b87c00649618843ea2d007d3dddeb145cd5ad398529
BLAKE2b-256 checksum
How to use checksums
4b7bd4322d4162bc33ac04751958d45486ab1a0742520d4d8e06e1cac53854d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.

Transparency log

Release files / lwpkt-2.0.0-py3-none-any.whl

Download URL lwpkt-2.0.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9871f86366430df155cbb885dcc8315b7f26d5f64ba1c189a50cc0dbcdd90163
BLAKE2b-256 checksum
How to use checksums
f70c0e79a07d2fe8f72b101b83314e78fe187f21fa44417af4c2d9c100c56178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page