tokio-socketcan-bcm

Crates.iotokio-socketcan-bcm
lib.rstokio-socketcan-bcm
version1.0.0
sourcesrc
created_at2019-03-12 20:39:46.213061
updated_at2020-09-23 06:18:15.781082
descriptionAsynchronous Linux SocketCAN - Broadcast Manager support (BCM) with tokio
homepagehttps://github.com/marcelbuesing/tokio-socketcan-bcm
repositoryhttps://github.com/marcelbuesing/tokio-socketcan-bcm.git
max_upload_size
id120354
size38,228
Marcel (marcelbuesing)

documentation

README

tokio-socketcan-bcm

LICENSE VERSION docs

The Broadcast Manager protocol provides a command based configuration interface to filter and send (e.g. cyclic) CAN messages in kernel space. Filtering messages in kernel space may significantly reduce the load in an application.

A BCM socket is not intended for sending individual CAN frames. To send invidiual frames use the tokio-socketcan crate.

This crate would not have been possible without the socketcan crate.

Example

use std::time;
use tokio_socketcan_bcm::*;
use futures_util::stream::StreamExt;

#[tokio::main]
async fn main() {
    let socket = BCMSocket::open_nb("vcan0").unwrap();
    let ival = time::Duration::from_millis(0);

    // create a stream of messages that filters by the can frame id 0x123
    let mut can_frame_stream = socket
        .filter_id_incoming_frames(0x123.into(), ival, ival)
        .unwrap();

    while let Some(frame) = can_frame_stream.next().await {
        println!("Frame {:?}", frame);
        ()
    }
}
Commit count: 12

cargo fmt