Node

Struct Node 

Source
pub struct Node<'a> { /* private fields */ }
Expand description

The main object representing a node

§Operation

The node is run by polling the Node::process method in your application. It is safe to call this method as frequently as you like. There is no hard minimum for call frequency, but calling your node’s responses to messages will be delayed until process is called, and this will slow down communication to your node. It is recommended to register a callback using NodeMbox::set_process_notify_callback, and use this callback to trigger an immediate call to process, e.g. by waking a task or signaling the processing thread.

Implementations§

Source§

impl<'a> Node<'a>

Source

pub fn new( node_id: NodeId, callbacks: Callbacks<'a>, mbox: &'a NodeMbox, state: &'a dyn NodeStateAccess, od: &'a [ODEntry<'a>], ) -> Self

Create a new Node

§Arguments
  • node_id - Initial node ID assignment
  • mbox - The NODE_MBOX object created by zencan-build
  • state - The NODE_STATE state object created by zencan-build
  • od - The OD_TABLE object containing the object dictionary created by zencan-build
Source

pub fn set_node_id(&mut self, node_id: NodeId)

Manually set the node ID. Changing the node id will cause an NMT comm reset to occur, resetting communication parameter defaults and triggering a bootup heartbeat message if the ID is valid. Setting the node ID to 255 will put the node into unconfigured mode.

Source

pub fn process(&mut self, now_us: u64) -> bool

Run periodic processing

This should be called periodically by the application so that the node can update it’s state, send periodic messages, process received messages, etc.

It is sufficient to call this based on a timer, but the NodeMbox object also provides a notification callback, which can be used by an application to accelerate the call to process when an action is required.

§Arguments
  • now_us: A monotonic time in microseconds. This is used for measuring time and triggering time-based actions such as heartbeat transmission or SDO timeout
§Returns

A boolean indicating if objects were updated. This will be true when an SDO download has been completed, or when one or more RPDOs have been received.

Source

pub fn node_id(&self) -> u8

Get the current Node ID

Source

pub fn nmt_state(&self) -> NmtState

Get the current NMT state of the node

Source

pub fn rx_message_count(&self) -> u32

Get the number of received messages

Auto Trait Implementations§

§

impl<'a> Freeze for Node<'a>

§

impl<'a> !RefUnwindSafe for Node<'a>

§

impl<'a> !Send for Node<'a>

§

impl<'a> !Sync for Node<'a>

§

impl<'a> Unpin for Node<'a>

§

impl<'a> !UnwindSafe for Node<'a>

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.