Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
icl_hardware::canopen_schunk::NMT Class Reference

The NMT class provides access to NMT functions of the canOpen protocol and keeps the NMT state of canOpen nodes. More...

#include <NMT.h>

List of all members.

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.

Detailed Description

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.

Definition at line 42 of file NMT.h.


Member Enumeration Documentation

NMT Command specifies what the state machine shall do value = "cs" as specified in ds301 7.2.8.3.1.1.

Enumerator:
NMT_STARTREMOTENODE 
NMT_STOPREMOTENODE 
NMT_ENTERPREOPERATIONAL 
NMT_RESETNODE 
NMT_RESETCOMMUNICATION 

Definition at line 50 of file NMT.h.

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.

Enumerator:
NMTS_STOPPED 
NMTS_PRE_OPERATIONAL 
NMTS_OPERATIONAL 
NMTS_INITIALISATION 

Definition at line 60 of file NMT.h.

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.

Enumerator:
NMTSS_INITIALISING 
NMTSS_RESET_APPLICATION 
NMTSS_RESET_COMMUNICATION 

Definition at line 69 of file NMT.h.


Constructor & Destructor Documentation

icl_hardware::canopen_schunk::NMT::NMT ( const uint8_t node_id,
const CanDevPtr can_device 
)

NMT Construct a new NMT object to manage the NMT state of a device.

Parameters:
node_idCanopen ID of the node to manage
can_deviceCan device handle for message sending

Definition at line 30 of file NMT.cpp.


Member Function Documentation

bool icl_hardware::canopen_schunk::NMT::isValidNmtState ( const uint8_t state) [inline, private]

isValidNmtState Helper function to check if a received value is a valid NMT state

Parameters:
stateValue to check if it is an NMT state
Returns:
true if the value is a valid NMT state

Definition at line 185 of file NMT.h.

const std::string icl_hardware::canopen_schunk::NMT::nmtCommandToString ( const eNMT_Command cmd) [inline, private]

commandToString Returns a string corresponding to a command enum.

Note:
One of the few options to "stringify" values without initializer lists (c++98)
Parameters:
cmdAn NMT command
Returns:
A string representing the given command

Definition at line 146 of file NMT.h.

const std::string icl_hardware::canopen_schunk::NMT::nmtStateToString ( const eNMT_State state) [inline, private]

nmtStateToString Returns a string corresponding to a given NMT state

Note:
One of the few options to "stringify" values without initializer lists (c++98)
Parameters:
stateAn NMT state
Returns:
A string representing the given state

Definition at line 167 of file NMT.h.

preOperational switches the device back into pre-operational state where configuration can occur

Definition at line 101 of file NMT.cpp.

reset Resets the device and triggers a complete reboot

Definition at line 106 of file NMT.cpp.

resetCommunication Resets the communication of a device, setting communication values to their defaults

Definition at line 111 of file NMT.cpp.

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.

Parameters:
cmdCommand to send via NMT protocol

Definition at line 116 of file NMT.cpp.

start Starts the device by setting the NMT state to operational

Definition at line 91 of file NMT.cpp.

stop Stops the device by setting the NMT state to stopped

Definition at line 96 of file NMT.cpp.

update Updates the NMT status with newly received data

Parameters:
msgcan 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).

Definition at line 37 of file NMT.cpp.


Member Data Documentation

can device handle for sending of NMT commands

Definition at line 202 of file NMT.h.

We keep the node ID which this NMT object is corresponding to.

Definition at line 205 of file NMT.h.

Status of the NMT state machine.

Definition at line 208 of file NMT.h.

Node ID of all nodes at once.

Definition at line 47 of file NMT.h.


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


schunk_canopen_driver
Author(s): Felix Mauch , Georg Heppner
autogenerated on Sun May 22 2016 03:30:57