KaCanOpen
 All Classes Functions Variables Typedefs Enumerations Pages
Public Types | Public Member Functions | List of all members
kaco::NMT Class Reference

This class implements the CanOpen NMT protocol. More...

#include <nmt.h>

Public Types

enum  Command : uint8_t {
  start_node = 0x01, stop_node = 0x02, enter_preoperational = 0x80, reset_node = 0x81,
  reset_communication = 0x82
}
 NMT commands.
 
using DeviceAliveCallback = std::function< void(const uint8_t node_id) >
 Type of a device alive callback function Important: Never call register_device_alive_callback() from within (-> deadlock)!
 
using NewDeviceCallback = DeviceAliveCallback
 Type of a new device callback function. More...
 

Public Member Functions

 NMT (Core &core)
 Constructor. More...
 
 NMT (const NMT &)=delete
 Copy constructor deleted because of mutexes.
 
void process_incoming_message (const Message &message)
 Process incoming NMT message. More...
 
void send_nmt_message (uint8_t node_id, Command cmd)
 Sends a NMT message to a given device. More...
 
void broadcast_nmt_message (Command cmd)
 Sends a broadcast NMT message. More...
 
void reset_all_nodes ()
 Resets all nodes in the network. More...
 
void discover_nodes ()
 Discovers nodes in the network via node guard protocol. More...
 
void register_device_alive_callback (const DeviceAliveCallback &callback)
 Registers a callback which will be called when a slave sends it's state via NMT and the state indicates that the device is alive. This can be uses as a "new device" callback. More...
 
void register_new_device_callback (const NewDeviceCallback &callback)
 Registers a callback which will be called when a new slave device is discovered. More...
 

Detailed Description

This class implements the CanOpen NMT protocol.

Definition at line 50 of file nmt.h.

Member Typedef Documentation

Type of a new device callback function.

Deprecated:

Definition at line 61 of file nmt.h.

Constructor & Destructor Documentation

kaco::NMT::NMT ( Core core)

Constructor.

Parameters
coreReference to the Core

Definition at line 43 of file nmt.cpp.

Member Function Documentation

void kaco::NMT::broadcast_nmt_message ( Command  cmd)

Sends a broadcast NMT message.

Parameters
cmdThe NMT command.
Remarks
thread-safe

Definition at line 53 of file nmt.cpp.

void kaco::NMT::discover_nodes ( )

Discovers nodes in the network via node guard protocol.

Remarks
thread-safe
Examples:
examples/ros/motor_and_io_bridge.cpp.

Definition at line 67 of file nmt.cpp.

void kaco::NMT::process_incoming_message ( const Message message)

Process incoming NMT message.

Parameters
messageThe received CanOpen message.
Remarks
thread-safe

Definition at line 79 of file nmt.cpp.

void kaco::NMT::register_device_alive_callback ( const DeviceAliveCallback callback)

Registers a callback which will be called when a slave sends it's state via NMT and the state indicates that the device is alive. This can be uses as a "new device" callback.

Remarks
thread-safe
Examples:
examples/core.cpp.

Definition at line 181 of file nmt.cpp.

void kaco::NMT::register_new_device_callback ( const NewDeviceCallback callback)

Registers a callback which will be called when a new slave device is discovered.

Remarks
thread-safe
Deprecated:

Definition at line 186 of file nmt.cpp.

void kaco::NMT::reset_all_nodes ( )

Resets all nodes in the network.

Remarks
thread-safe
Examples:
examples/core.cpp.

Definition at line 57 of file nmt.cpp.

void kaco::NMT::send_nmt_message ( uint8_t  node_id,
Command  cmd 
)

Sends a NMT message to a given device.

Parameters
node_idNode id of the device.
cmdThe NMT command.
Remarks
thread-safe
Examples:
examples/core.cpp.

Definition at line 47 of file nmt.cpp.


The documentation for this class was generated from the following files: