.. _rust_getting_started: ========================================== Rust Quickstart (`rustflexstack`) ========================================== The ``rustflexstack`` crate provides a high-performance, memory-safe ETSI C-ITS Release 2 protocol stack in pure Rust. It runs natively, without a garbage collector, on embedded automotive hardware (e.g. Cohda MK6 OBUs, Raspberry Pi). Precompiled Binaries (Fastest Option) ===================================== If you want to quickly test or deploy without setting up a Rust development environment or compiling from source, you can download precompiled standalone Linux binaries directly from the GitHub Releases page: * **GitHub Releases**: https://github.com/Fundacio-i2CAT/RustFlexstack/releases/latest The release provides precompiled Linux binaries of ``v2x_cli`` for both major CPU architectures: * **x86_64** (Intel/AMD Linux desktops and servers) * **aarch64** (Arm64 platforms such as Raspberry Pi 5, automotive single-board computers, and embedded Linux boards) Simply download the binary corresponding to your architecture, make it executable, and run: .. code-block:: bash # Example for x86_64 or aarch64 chmod +x v2x_cli sudo ./v2x_cli -i eth0 --send cam Prerequisites & Toolchain (Building from Source) ================================================= * **Rust Toolchain**: a stable Rust toolchain (edition 2021; the 0.4.0 release is built with Rust 1.95). Install via `rustup `_: .. code-block:: bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh * **Platform Privileges**: Raw Ethernet or IEEE 802.11p packet injection requires root privileges (``sudo``) or Linux ``CAP_NET_RAW`` capability. Adding Dependency to Cargo.toml =============================== Add ``rustflexstack`` to your project's ``Cargo.toml``: .. code-block:: toml [dependencies] rustflexstack = "0.4.0" To enable Qualcomm C-V2X direct radio support: .. code-block:: toml [dependencies] rustflexstack = { version = "0.4.0", features = ["cv2x"] } Building the Library & Examples =============================== Clone and build the repository: .. code-block:: bash git clone https://github.com/Fundacio-i2CAT/RustFlexstack.git cd RustFlexstack cargo build --release Running the Built-in Examples ============================= 1. Command-Line Station (CAM, VAM, DENM reception) -------------------------------------------------- The included ``v2x_cli`` example provides a full-featured command-line utility for transmitting and receiving ETSI messages: .. code-block:: bash # Transmit CAMs over Ethernet interface eth0 sudo cargo run --example v2x_cli -- --iface eth0 --send cam # Transmit signed CAMs (needs the chain of generate_certificate_chain in certs/) sudo cargo run --example v2x_cli -- --iface eth0 --send cam --security # Connect to live GPSD daemon for ego coordinates sudo cargo run --example v2x_cli -- --iface eth0 --send cam --gpsd 127.0.0.1:2947 # Receive and decode all incoming V2X messages sudo cargo run --example v2x_cli -- --iface eth0 # receive-only (default) 2. DENM Sender & Receiver ------------------------- Broadcast road hazard event notifications: .. code-block:: bash sudo cargo run --example denm_sender_receiver -- eth0 # interface, default lo 3. Generate Certificate Chains ------------------------------ Generate root CA, authorization authority (AA), and authorization tickets (AT) conforming to ETSI TS 103 097: .. code-block:: bash cargo run --example generate_certificate_chain Generating Local API Documentation ================================== You can generate and view the interactive rustdoc reference locally: .. code-block:: bash cargo doc --open --no-deps