Skip to main content

SocketCanBus

Struct SocketCanBus 

Source
pub struct SocketCanBus { /* private fields */ }
Expand description

Linux SocketCAN bus.

Implementations§

Source§

impl SocketCanBus

Source

pub fn open(interface: &str, fd_enabled: bool) -> Result<Self, TransportError>

Open a SocketCAN interface.

With fd_enabled = true the socket is configured for CAN-FD (CAN_RAW_FD_FRAMES) and the bus advertises BusCapabilities::fd(); the interface itself must be FD-capable. With fd_enabled = false the bus is classical-only (no FD socket option, 8-byte payload cap).

Trait Implementations§

Source§

impl CanBus for SocketCanBus

Source§

fn name(&self) -> &str

Human-readable interface name ("vcan0", "can0", "mock-0").
Source§

fn capabilities(&self) -> BusCapabilities

Runtime capabilities of this bus (FD support, max payload length).
Source§

fn send(&mut self, frame: &CanFrame) -> Result<(), TransportError>

Send a single frame. Must not call read or poll internally.
Source§

fn drain_inbound_nonblocking(&mut self) -> Result<Vec<CanFrame>, TransportError>

Drain every frame currently in the receive queue and return them in arrival order. Returns Ok(vec![]) immediately if the queue is empty.
Source§

fn raw_fd(&self) -> Option<RawFd>

Pollable file descriptor for poll(2)-based multiplexing. Returns None for transports that have no single pollable fd. The robot drains those transports from memory on every crate::Robot::tick call.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.