LssMaster

Struct LssMaster 

Source
pub struct LssMaster<S, R> { /* private fields */ }
Expand description

Struct to interact with nodes using the LSS protocol

Implementations§

Source§

impl<S: AsyncCanSender, R: AsyncCanReceiver> LssMaster<S, R>

Source

pub fn new(sender: S, receiver: R) -> Self

Create a new LssMaster

§Arguments
  • sender: An object which implements AsyncCanSender to be used for sending messages to the bus
  • receiver: An object which implements AsyncCanReceiver to be used for receiving messages from the bus

When using socketcan, these can be created with crate::open_socketcan.

Source

pub async fn configure_by_identity( &mut self, identity: LssIdentity, node_id: NodeId, baud_rate_table: u8, baud_rate_index: u8, ) -> Result<(), LssError>

Configure an LSS slave with known identity

If you know the 128-bit identity value for a node, you can configure it this way.

Source

pub async fn enter_config_by_identity( &mut self, vendor_id: u32, product_code: u32, revision: u32, serial: u32, ) -> Result<(), LssError>

Send a sequence of messages to put a single node into configuration mode based on its identity

Source

pub async fn set_baud_rate( &mut self, table: u8, index: u8, ) -> Result<(), LssError>

Send a command to set the baud rate on the LSS slave current in configuration mode

The node must have been put into configuration mode already.

Returns Err(LssError::Timeout) if the node does not respond to the command, or Err(LssError::ConfigError) if the node responds with an error.

§Arguments
  • table - The index of the table of baud rate settings to use (0 for the default CANOpen table)
  • index - The index into the table of the baud rate setting to use
Source

pub async fn set_node_id(&mut self, node_id: NodeId) -> Result<(), LssError>

Send a command to set the node ID on the LSS slave current in configuration mode

The node must have been put into configuration mode already.

Returns Err(LssError::Timeout) if the node does not respond to the command, or Err(LssError::ConfigError) if the node responds with an error.

Source

pub async fn store_config(&mut self) -> Result<(), LssError>

Send command to store configuration

The node must have been put into configuration mode already.

Returns Err(LssError::Timeout) if the node does not respond to the command, or Err(LssError::ConfigError) if the node responds with an error.

Source

pub async fn fast_scan(&mut self, timeout: Duration) -> Option<LssIdentity>

Perform a fast scan of the network to find unconfigured nodes

§Arguments
  • timeout - The duration of time to wait for responses after each message. Duration::from_millis(20) is probably a pretty safe value, but this depends on the responsiveness of the slaves, and on the amount of bus traffic. If the timeout is set too short, the scan may fail to find existing nodes.
Source

pub async fn set_global_mode(&mut self, mode: LssState)

Send command to the bus to set the LSS mode for all nodes

Trait Implementations§

Source§

impl<S: Debug, R: Debug> Debug for LssMaster<S, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, R> Freeze for LssMaster<S, R>
where S: Freeze, R: Freeze,

§

impl<S, R> RefUnwindSafe for LssMaster<S, R>

§

impl<S, R> Send for LssMaster<S, R>
where S: Send, R: Send,

§

impl<S, R> Sync for LssMaster<S, R>
where S: Sync, R: Sync,

§

impl<S, R> Unpin for LssMaster<S, R>
where S: Unpin, R: Unpin,

§

impl<S, R> UnwindSafe for LssMaster<S, R>
where S: UnwindSafe, R: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.