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... | |
kaco::NMT::NMT | ( | Core & | core | ) |
void kaco::NMT::broadcast_nmt_message | ( | Command | cmd | ) |
void kaco::NMT::discover_nodes | ( | ) |
Discovers nodes in the network via node guard protocol.
void kaco::NMT::process_incoming_message | ( | const Message & | message | ) |
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.
void kaco::NMT::register_new_device_callback | ( | const NewDeviceCallback & | callback | ) |
Registers a callback which will be called when a new slave device is discovered.
void kaco::NMT::reset_all_nodes | ( | ) |
void kaco::NMT::send_nmt_message | ( | uint8_t | node_id, |
Command | cmd | ||
) |
Sends a NMT message to a given device.
node_id | Node id of the device. |
cmd | The NMT command. |