BusManager

Struct BusManager 

Source
pub struct BusManager<S: AsyncCanSender + Sync + Send> { /* private fields */ }
Expand description

Manage a zencan bus

Implementations§

Source§

impl<S: AsyncCanSender + Sync + Send> BusManager<S>

Source

pub fn new(sender: S, receiver: impl AsyncCanReceiver + Sync + 'static) -> Self

Create a new bus manager

§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 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.

Source

pub async fn node_list(&self) -> Vec<NodeInfo>

Get a list of known nodes

Source

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
Source

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

Source

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().

Source

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

Source

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

Source

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

Send a command to put all devices into the specified LSS state

Source

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

Source

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

Source

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

Source

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

Source

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§

Source§

impl<S: Debug + AsyncCanSender + Sync + Send> Debug for BusManager<S>

Source§

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

Formats the value using the given formatter. Read more

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> 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.