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>
impl<S: AsyncCanSender, R: AsyncCanReceiver> LssMaster<S, R>
Sourcepub fn new(sender: S, receiver: R) -> Self
pub fn new(sender: S, receiver: R) -> Self
Create a new LssMaster
§Arguments
sender: An object which implementsAsyncCanSenderto be used for sending messages to the busreceiver: An object which implementsAsyncCanReceiverto be used for receiving messages from the bus
When using socketcan, these can be created with crate::open_socketcan.
Sourcepub async fn configure_by_identity(
&mut self,
identity: LssIdentity,
node_id: NodeId,
baud_rate_table: u8,
baud_rate_index: u8,
) -> Result<(), LssError>
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.
Sourcepub async fn enter_config_by_identity(
&mut self,
vendor_id: u32,
product_code: u32,
revision: u32,
serial: u32,
) -> Result<(), LssError>
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
Sourcepub async fn set_baud_rate(
&mut self,
table: u8,
index: u8,
) -> Result<(), LssError>
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
Sourcepub async fn set_node_id(&mut self, node_id: NodeId) -> Result<(), LssError>
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.
Sourcepub async fn store_config(&mut self) -> Result<(), LssError>
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.
Sourcepub async fn fast_scan(&mut self, timeout: Duration) -> Option<LssIdentity>
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.
Sourcepub async fn set_global_mode(&mut self, mode: LssState)
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§
Auto Trait Implementations§
impl<S, R> Freeze for LssMaster<S, R>
impl<S, R> RefUnwindSafe for LssMaster<S, R>where
S: RefUnwindSafe,
R: RefUnwindSafe,
impl<S, R> Send for LssMaster<S, R>
impl<S, R> Sync for LssMaster<S, R>
impl<S, R> Unpin for LssMaster<S, R>
impl<S, R> UnwindSafe for LssMaster<S, R>where
S: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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