Rust Cooperative Awareness (CAM)

The rustflexstack::facilities::ca_basic_service module implements ETSI TS 103 900 V2.3.1 (Cooperative Awareness Messages).

Components

  • cam_bindings: Rust types for the CAM containers, generated with rasn from the official ASN.1 modules.

  • cam_coder: CamCoder, the UPER encoder and decoder, and the Cam type.

  • cam_transmission: the generation rules: dynamics-triggered intervals between T_GenCamMin (100 ms) and T_GenCamMax (1 s), bounded by the DCC interval T_GenCam_DCC, with low-frequency and special-vehicle containers.

  • cam_reception: decodes received CAMs, checks their SSP and stores them in the LDM.

Encoding & Decoding CAMs

use rustflexstack::facilities::ca_basic_service::cam_coder::{Cam, CamCoder};

let coder = CamCoder::new();
let raw_uper_bytes: Vec<u8> = vec![/* a received CAM */];
match coder.decode(&raw_uper_bytes) {
    Ok(cam) => {
        println!("CAM from station {:?}", cam.header.station_id);
        let encoded: Vec<u8> = coder.encode(&cam).expect("CAM encoding failed");
        println!("re-encoded to {} bytes", encoded.len());
    }
    Err(e) => eprintln!("{e}"),
}

A complete station that sends and receives CAMs is examples/v2x_cli.rs (see Rust V2X CLI Tool Tutorial (v2x_cli)).