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>
impl<'a> Node<'a>
Sourcepub fn new(
node_id: NodeId,
callbacks: Callbacks<'a>,
mbox: &'static NodeMbox,
state: &'static NodeState<'static>,
od: &'static [ODEntry<'static>],
) -> Self
pub fn new( node_id: NodeId, callbacks: Callbacks<'a>, mbox: &'static NodeMbox, state: &'static NodeState<'static>, od: &'static [ODEntry<'static>], ) -> Self
Sourcepub fn set_node_id(&mut self, node_id: NodeId)
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.
Sourcepub fn process(&mut self, now_us: u64) -> bool
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.
Sourcepub fn rx_message_count(&self) -> u32
pub fn rx_message_count(&self) -> u32
Get the number of received messages