pub struct BusManager<S: AsyncCanSender + Sync + Send> { /* private fields */ }Expand description
Manage a zencan bus
Implementations§
Source§impl<S: AsyncCanSender + Sync + Send> BusManager<S>
impl<S: AsyncCanSender + Sync + Send> BusManager<S>
Sourcepub fn new(sender: S, receiver: impl AsyncCanReceiver + Sync + 'static) -> Self
pub fn new(sender: S, receiver: impl AsyncCanReceiver + Sync + 'static) -> Self
Create a new bus manager
§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 fn sdo_client(
&self,
node_id: u8,
) -> SdoClientGuard<'_, SharedSender<S>, SharedReceiverChannel>
pub fn sdo_client( &self, node_id: u8, ) -> SdoClientGuard<'_, SharedSender<S>, SharedReceiverChannel>
Get an SDO client for a particular node
This function may block if another task is using the required SDO client, as it ensures exclusive access to each node’s SDO server.
Sourcepub async fn scan_nodes(&mut self) -> Result<Vec<NodeInfo>, SdoClientError>
pub async fn scan_nodes(&mut self) -> Result<Vec<NodeInfo>, SdoClientError>
Perform a scan of all possible node IDs
Will find all configured devices, and read metadata from required objects, including:
- Identity
- Device Name
- Software Version
- Hardware Version
Sourcepub async fn lss_fastscan(&mut self, timeout: Duration) -> Vec<LssIdentity>
pub async fn lss_fastscan(&mut self, timeout: Duration) -> Vec<LssIdentity>
Find all unconfigured devices on the bus
The LSS fastscan protocol is used to identify devices which do not have an assigned node ID.
Devices that do have a node ID can be found using scan_nodes, or by
their heartbeat messages.
After devices are found, they are all put back into waiting state
Sourcepub async fn lss_activate(&mut self, ident: LssIdentity) -> Result<(), LssError>
pub async fn lss_activate(&mut self, ident: LssIdentity) -> Result<(), LssError>
Activate a single LSS slave by its identity
All nodes are put into Waiting mode via the global command, then the specified node is
activates. Will return Ok(()) if the activated node acknowledges, or an Err otherwise.
The identity consists of the four u32 values from the 0x1018 object, which should uniquely
identify a device on the bus. If they are not known, they can be found using
lss_fastscan().
Sourcepub async fn lss_set_node_id(&mut self, node_id: NodeId) -> Result<(), LssError>
pub async fn lss_set_node_id(&mut self, node_id: NodeId) -> Result<(), LssError>
Set the node ID of LSS slave in Configuration mode
It is required that one node has been put into Configuration mode already when this is
called, e.g. using lss_activate
Sourcepub async fn lss_store_config(&mut self) -> Result<(), LssError>
pub async fn lss_store_config(&mut self) -> Result<(), LssError>
Command the node in Configuration mode to store its configuration
It is required that one node has been put into Configuration mode already when this is
called, e.g. using lss_activate
Sourcepub async fn lss_set_global_mode(&mut self, mode: LssState)
pub async fn lss_set_global_mode(&mut self, mode: LssState)
Send a command to put all devices into the specified LSS state
Sourcepub async fn nmt_reset_app(&mut self, node: u8)
pub async fn nmt_reset_app(&mut self, node: u8)
Send application reset command
node - The node ID to command, or 0 to broadcast to all nodes
Sourcepub async fn nmt_reset_comms(&mut self, node: u8)
pub async fn nmt_reset_comms(&mut self, node: u8)
Send communications reset command
node - The node ID to command, or 0 to broadcast to all nodes
Sourcepub async fn nmt_start(&mut self, node: u8)
pub async fn nmt_start(&mut self, node: u8)
Send start operation command
node - The node ID to command, or 0 to broadcast to all nodes
Sourcepub async fn nmt_stop(&mut self, node: u8)
pub async fn nmt_stop(&mut self, node: u8)
Send start operation command
node - The node ID to command, or 0 to broadcast to all nodes
Sourcepub async fn read_pdo_config(
&mut self,
node: ConfiguredNodeId,
) -> Result<PdoScanResult, SdoClientError>
pub async fn read_pdo_config( &mut self, node: ConfiguredNodeId, ) -> Result<PdoScanResult, SdoClientError>
Read the RPDO and TPDO configuration for the specified node
node - The node ID to read from
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for BusManager<S>
impl<S> !RefUnwindSafe for BusManager<S>
impl<S> Send for BusManager<S>
impl<S> Sync for BusManager<S>
impl<S> Unpin for BusManager<S>
impl<S> !UnwindSafe for BusManager<S>
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