The NMT class provides access to NMT functions of the canOpen protocol and keeps the NMT state of canOpen nodes. More...
#include <NMT.h>
Public Types | |
enum | eNMT_Command { NMT_STARTREMOTENODE = 0x01, NMT_STOPREMOTENODE = 0x02, NMT_ENTERPREOPERATIONAL = 0x80, NMT_RESETNODE = 0x81, NMT_RESETCOMMUNICATION = 0x82 } |
NMT Command specifies what the state machine shall do value = "cs" as specified in ds301 7.2.8.3.1.1. More... | |
enum | eNMT_State { NMTS_STOPPED = 0x04, NMTS_PRE_OPERATIONAL = 0x7F, NMTS_OPERATIONAL = 0x05, NMTS_INITIALISATION = 0x00 } |
The NMT state indicates the behavior of the communication of a device, everything else is device specific. Only state operational allows PDO communication. See DS301 7.3.2.2. More... | |
enum | eNMT_SubState { NMTSS_INITIALISING, NMTSS_RESET_APPLICATION, NMTSS_RESET_COMMUNICATION } |
The NMT Substate is only used during initialization of a device. Meaning the substates are only useful if we want to implement a slave ourselves. More... | |
Public Member Functions | |
NMT (const uint8_t &node_id, const CanDevPtr &can_device) | |
NMT Construct a new NMT object to manage the NMT state of a device. | |
void | preOperational () |
preOperational switches the device back into pre-operational state where configuration can occur | |
void | reset () |
reset Resets the device and triggers a complete reboot | |
void | resetCommunication () |
resetCommunication Resets the communication of a device, setting communication values to their defaults | |
void | start () |
start Starts the device by setting the NMT state to operational | |
void | stop () |
stop Stops the device by setting the NMT state to stopped | |
void | update (const CanMsg &msg) |
update Updates the NMT status with newly received data | |
Static Public Attributes | |
static const uint8_t | NMT_ALL_NODES = 0x00 |
Node ID of all nodes at once. | |
Private Member Functions | |
bool | isValidNmtState (const uint8_t &state) |
isValidNmtState Helper function to check if a received value is a valid NMT state | |
const std::string | nmtCommandToString (const eNMT_Command &cmd) |
commandToString Returns a string corresponding to a command enum. | |
const std::string | nmtStateToString (const eNMT_State &state) |
nmtStateToString Returns a string corresponding to a given NMT state | |
void | sendCommand (const eNMT_Command &cmd) |
sendCommand Sends an actual NMT command to the device. This will proactively change the state of the NMT object which is important for the error handling. | |
Private Attributes | |
CanDevPtr | m_can_device |
can device handle for sending of NMT commands | |
uint8_t | m_node_id |
We keep the node ID which this NMT object is corresponding to. | |
eNMT_State | m_state |
Status of the NMT state machine. |
The NMT class provides access to NMT functions of the canOpen protocol and keeps the NMT state of canOpen nodes.
NMT is the protocol layer that handles the state of individual nodes. It can be used to set the controlled devices into operational state, shut them down etc. This class provides access to those functions, handles incoming NMT messages and keeps track of the NMT State of the individual nodes.
icl_hardware::canopen_schunk::NMT::NMT | ( | const uint8_t & | node_id, |
const CanDevPtr & | can_device | ||
) |
bool icl_hardware::canopen_schunk::NMT::isValidNmtState | ( | const uint8_t & | state | ) | [inline, private] |
const std::string icl_hardware::canopen_schunk::NMT::nmtCommandToString | ( | const eNMT_Command & | cmd | ) | [inline, private] |
const std::string icl_hardware::canopen_schunk::NMT::nmtStateToString | ( | const eNMT_State & | state | ) | [inline, private] |
void icl_hardware::canopen_schunk::NMT::sendCommand | ( | const eNMT_Command & | cmd | ) | [private] |
void icl_hardware::canopen_schunk::NMT::update | ( | const CanMsg & | msg | ) |
update Updates the NMT status with newly received data
msg | can message that has been identified as NMT message |
This function updates the NMT State of nodes by parsing received NMT messages.
NMT: AN NMT message with the ID 0x00 is the NMT command message. This is only relevant in case we are a slave node.
NMT ERROR/HEARTBEAT: CAN-ID =1792 + Node ID = Boot Up Message from the devices when they change from initialization to pre operational (payload = 0) This transition is automatic once the device has initialized all its values. If the Heartbeat node guarding is used the device will also send the same message periodically indicating the NMT state in the lower 7 bit of the 1 byte payload. Bit 7 is always 0. The value sent is given in as eNMT_State value. In case the heartbeat time is configured, the heartbeat producer time starts immediately, in case it remains unchanged the time starts after the bootup event. The Heartbeat protocol is used if the heartbeat producer time is unequal 0.
NMT ERROR/NODE GUARDING: With Node Guarding protocol the master (we) poll the device information by sending a remote transmission request to the node The node answers wit CAN-ID = 1792 + Node-ID messages as with the heartbeat. Bit 0..6 are the status as with the heartbeat. Bit 7 is a toggle bit that needs to alternate. Requests are sent in intervals given by the node guarding time. If no response is received within the node life time = node guarding time * lifetime factor the master indicates a "node guarding event" and the device a "life guarding event". If the received status does not match the expected one a "node guarding event" is to be triggered (meaning a fault occurred).
const uint8_t icl_hardware::canopen_schunk::NMT::NMT_ALL_NODES = 0x00 [static] |