[][src]Struct tokio_socketcan_bcm::BCMSocket

pub struct BCMSocket {
    pub fd: c_int,
}

A socket for a CAN device, specifically for broadcast manager operations.

Fields

fd: c_int

Implementations

impl BCMSocket[src]

pub fn open_nb(ifname: &str) -> Result<BCMSocket>[src]

Open a named CAN device non blocking.

Usually the more common case, opens a socket can device by name, such as "vcan0" or "socan0".

pub fn open_if_nb(if_index: c_uint) -> Result<BCMSocket>[src]

Open CAN device by interface number non blocking.

Opens a CAN device by kernel interface number.

pub fn filter_id(
    &self,
    can_id: CANMessageId,
    ival1: Duration,
    ival2: Duration
) -> Result<()>
[src]

Create a content filter subscription, filtering can frames by can_id.

pub fn filter_id_incoming_frames(
    self,
    can_id: CANMessageId,
    ival1: Duration,
    ival2: Duration
) -> Result<BcmFrameStream>
[src]

Combination of BCMSocket::filter_id and BCMSocket::incoming_frames.

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);
        ()
    }
}

pub fn incoming_msg(self) -> Result<BcmStream>[src]

Stream of incoming BcmMsgHeads that apply to the filter criteria.

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
        .incoming_msg()
        .unwrap();

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

pub fn incoming_frames(self) -> Result<BcmFrameStream>[src]

Stream of incoming frames that apply to the filter criteria.

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
        .incoming_frames()
        .unwrap();

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

pub fn filter_delete(&self, can_id: CANMessageId) -> Result<()>[src]

Remove a content filter subscription.

pub fn read_msg(&self) -> Result<BcmMsgHead>[src]

Read a single bcm message.

Trait Implementations

impl Debug for BCMSocket[src]

impl Drop for BCMSocket[src]

impl Evented for BCMSocket[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err