This package provides high-performance Python bindings for the SAE J2735 (202409) V2X codec. Powered by WebAssembly (WASM), it allows for seamless, safe, and portable conversion between JSON (JER) and Packed Encoding Rules (UPER) within Python applications.
- Python:
v3.13or higher. - WASM Runtime: wasmtime (installed automatically as a dependency).
The fastest way to install the bindings is to use the pre-built Wheel (.whl) from the Releases page.
Using uv (Recommended):
uv pip install "https://github.com/verizon/j2735codec/releases/download/v1.0.0/python-j2735codec-1.0.0-py3-none-any.whlUsing pip:
pip install "https://github.com/verizon/j2735codec/releases/download/v1.0.0/python-j2735codec-1.0.0-py3-none-any.whl"The Python interface is designed to be simple and idiomatic.
from j2735codec import J2735Codec, EncodingRules, PDUTypes
# Initialize the codec
codec = J2735Codec()
# Example JSON Message Frame
json_content = '{"messageFrame": {"messageId": 20, "value": { ... }}}'
# 1. Transcode: JSON (JER) -> Packed (UPER)
uper_bytes = codec.transcode(
input_encoding=EncodingRules.JER,
output_encoding=EncodingRules.UNALIGNED_BASIC_PER,
pdu=PDUTypes.MESSAGE_FRAME,
buffer=json_content
)
print(f"Encoded UPER (Hex): {uper_bytes.hex().upper()}")
# 2. Transcode: Packed (UPER) -> JSON (JER)
decoded_json_raw = codec.transcode(
input_encoding=EncodingRules.UNALIGNED_BASIC_PER,
output_encoding=EncodingRules.JER,
pdu=PDUTypes.MESSAGE_FRAME,
buffer=uper_bytes
)
print(f"Decoded JSON: {decoded_json_raw.decode('utf-8')}")The recommended way of installing and building is through the root Makefile. If you wish to work on the bindings directly though, here are some tips to help.
The Python bindings require a compiled WebAssembly binary. If you modify the C++ core, refresh the artifacts from the project root:
# From the project root
make wasm
This places j2735.wasm and metadata into src/j2735codec/generated/.
We use uv for fast, reproducible environment management.
cd j2735codec/bindings/python
uv syncTo package the bindings for distribution, use the uv build command:
- File:
python-j2735codec-<version>-py3-none-any.whl - Purpose: This "Universal Wheel" contains the Python source and the bundled WASM binary.
pip install ./python-j2735codec-1.0.0-py3-none-any.whlRun the test suite using pytest:
uv run pytestThis package follows Unified Versioning. The version in pyproject.toml must match the root VERSION file and CMakeLists.txt.
Warning: Do not bump versions manually. Use
make sync-versionfrom the root directory.
Licensed under the Apache License 2.0. See LICENSE for details.