Skip to content

Latest commit

 

History

History
167 lines (108 loc) · 5.04 KB

File metadata and controls

167 lines (108 loc) · 5.04 KB

The J2735 Codec

The J2735 codec is responsible for transforming V2X messages into a standardized form for consumption amongst various parties. This codec is based on C/C++ codebase generated from ASN.1 compiler.

In order to provide a better onboarding experience, the native codebase is transformed into WebAssembly (WASM) in the project to provide a safe, fast, and portable codec for Python, Node, and other modern runtimes. A very thin layer of wrapper code sits on top of the WebAssembly to help facilitate the interaction with the WebAssembly. This makes the encoding and decoding process between the different message format easier for the developers. These two components form the basis of the codec.

⚠️WARNING⚠️ : WebAssembly is not thread-safe; ensure there is no concurrent access to the codec library. Instead of sharing a single resource via threads or async tasks, always create separate, isolated instances.

Note: The original C/C++ code is also provided in the project. Compiling the source code into a C static library is also supported.

Supported Standards

Supported Bindings

Currently, the following language bindings are officially supported and maintained:

Language Status Runtime Dependency Documentation
Python ✅ Active wasmtime View Python README
Node.js ✅ Active Native Support View Node README

For specific installation steps and examples for Python or Node, please view the language's README.

Source Installation

Prerequisites

Runtime & Package Managers

  • For Node.js: v22.16.0 (LTS) or higher.

    • NPM is needed for the builds to work.
  • For Python: v3.13 or higher.

    • UV or Pip should be installed for builds to work.

Emscripten SDK (emsdk)

  • Required to compile the C++ source into WebAssembly.

  • Tested Version: 4.0.10

  • Note: It is recommended to use the version listed above to ensure consistent WASM memory exports.

    # Clone and install the Emscripten toolchain
    git clone https://github.com/emscripten-core/emsdk.git
    cd emsdk
    ./emsdk install 4.0.10
    ./emsdk activate 4.0.10
    
    # Activate environment variables (must be run in every new terminal session)
    source ./emsdk_env.sh

CMake (3.23+)

  • Used to manage the C++ build process.
  • macOS: brew install cmake
  • Linux: sudo apt install cmake
  • Windows: Download from cmake.org

Instructions

The first step is to clone this repository first. All of the following commands should be executed from the project root.

git clone https://github.com/Verizon/EdgeTransportationExchange_SampleClient.git
cd EdgeTransportationExchange_SampleClient/j2735codec

The following commands will perform a full installation outlined below:

Setup → Build → Test Code → Pack Artifacts → Verify Package Installation

Python

make install-py

Node.js

make install-js

If anything goes wrong a "hard reset" can be performed using the following command. Use this for a completely fresh start.

make purge

Advanced Building & Management

The make install-py or make install-js command is really all you need to get started. It essentially operates all the following commands in a sequence. If you want more control over the build and install process, the following commands are available as well. The central Makefile at the root of the repository orchestrates all of the commands.

Note: There are interdependencies across the following commands. For example, if you run build, setup and wasm compilation will be run as well.

WebAssembly Compilation

Compile codec C/C++ source into WebAssembly binary:

make wasm

Note: Ensure you have sourced your emsdk_env.sh before running this command.

Build Native C Library

Compile codec C/C++ source into a static C library (sample code is not provided for native C libraries):

make native

Environment Setup

Sync all dependencies (Python packages and Node modules):

make setup-py       # python
make setup-js       # node
make setup          # both

Build Bindings

make build-py       # python
make build-js       # node

Run Bindings Test

make test-py        # python
make test-js        # node

Uninstall Bindings

Uninstall the codec bindings from your local environment.

make uninstall-py   # python
make uninstall-js   # node

Cleanup

Removes language-specific build artifacts (dist and any output folders).

make clean-py   # python
make clean-js   # node

Purge

The purge command will perform a hard reset on the repository. Removing all distributions, binaries, installation, package manager, etc.

make purge