Nmt

Nmt

CANopen NMT protocol handler.

The network management (NMT) protocol follows a producer-consumer structure where NMT objects are used to initialze, start, monitor, reset, or stop nodes. All CANopen devices are considered NMT consumers with one device fulfilling the role of NMT producer.

This class implements the NMT node control services and tracks the device's current NMT consumer state.

Constructor

new Nmt(eds)

Source:
Implements:
See:
  • CiA301 "Network management" (§7.2.8)
Parameters:
Name Type Description
eds Eds

Eds object.

Members

producerTime :number

Description:
  • Get object 0x1017 - Producer heartbeat time.

Source:
Deprecated:

Get object 0x1017 - Producer heartbeat time.

Type:
  • number

producerTime :number

Description:
  • Set object 0x1017 - Producer heartbeat time.

Source:
Deprecated:

Set object 0x1017 - Producer heartbeat time.

Type:
  • number

state :NmtState

Description:
  • Device NMT state.

Source:

Device NMT state.

Type:

timers :Array

Description:
  • Consumer heartbeat timers (deprecated).

Source:
Deprecated:
  • Yes

Consumer heartbeat timers (deprecated).

Type:
  • Array

Methods

addConsumer(deviceId, timeout, subIndexopt)

Description:
  • Add an entry to 0x1016 (Consumer heartbeat time).

Source:
Deprecated:
Parameters:
Name Type Attributes Description
deviceId number

device COB-ID to add.

timeout number

milliseconds before a timeout is reported.

subIndex number <optional>

sub-index to store the entry, optional.

enterPreOperational(nodeIdopt)

Description:
  • Service: enter pre-operational.

    Change the state of NMT consumer(s) to NMT state pre-operational.

Source:
See:
  • CiA301 "Service enter pre-operational" (§7.2.8.2.1.4)
Parameters:
Name Type Attributes Description
nodeId number <optional>

id of node or 0 for broadcast.

getConsumer(deviceId) → {DataObject|null}

Description:
  • Get an entry from 0x1016 (Consumer heartbeat time).

Source:
Deprecated:
Parameters:
Name Type Description
deviceId number

device COB-ID of the entry to get.

Returns:

the matching entry or null.

Type
DataObject | null

getConsumerTime(deviceId) → {number|null}

Description:
  • Get the consumer heartbeat time for a device.

Source:
Since:
  • 5.1.0
Parameters:
Name Type Description
deviceId number

device COB-ID to get.

Returns:

the consumer heartbeat time or null.

Type
number | null

(async) getNodeState(…args) → {Promise.<(NmtState|null)>}

Description:
  • Get a device's NMT state.

Source:
Since:
  • 6.0.0
Parameters:
Name Type Attributes Description
args object <repeatable>

arguments.

Properties
Name Type Description
deviceId number

CAN identifier (defaults to this device).

timeout number

How long to wait for a new heartbeat (ms).

Returns:

The node NMT state or null.

Type
Promise.<(NmtState|null)>

init()

Description:
  • Initialize the device and audit the object dictionary.

Source:
Deprecated:

receive(message)

Description:
  • Call when a new CAN message is received.

Source:
Implements:
Parameters:
Name Type Description
message object

CAN frame.

Properties
Name Type Description
id number

CAN message identifier.

data Buffer

CAN message data;

Fires:

removeConsumer(deviceId)

Description:
  • Remove an entry from 0x1016 (Consumer heartbeat time).

Source:
Deprecated:
Parameters:
Name Type Description
deviceId number

device COB-ID of the entry to remove.

resetCommunication(nodeIdopt)

Description:
  • Service: reset communication.

    Reset communication of NMT consumer(s).

Source:
See:
  • CiA301 "Service reset communication" (§7.2.8.2.1.6)
Parameters:
Name Type Attributes Description
nodeId number <optional>

id of node or 0 for broadcast.

Fires:

resetNode(nodeIdopt)

Description:
  • Service: reset node.

    Reset the application of NMT consumer(s).

Source:
See:
  • CiA301 "Service reset node" (§7.2.8.2.1.5)
Parameters:
Name Type Attributes Description
nodeId number <optional>

id of node or 0 for broadcast.

Fires:

setState(state)

Description:
  • Set the Nmt state.

Source:
Parameters:
Name Type Description
state NmtState

new state.

Fires:

start()

Description:
  • Start the module.

Source:
Implements:
Fires:

startNode(nodeIdopt)

Description:
  • Service: start remote node.

    Change the state of NMT consumer(s) to NMT state operational.

Source:
See:
  • CiA301 "Service start remote node" (§7.2.8.2.1.2)
Parameters:
Name Type Attributes Description
nodeId number <optional>

id of node or 0 for broadcast.

stop()

Description:
  • Stop the module.

Source:
Implements:
Fires:

stopNode(nodeIdopt)

Description:
  • Service: stop remote node.

    Change the state of NMT consumer(s) to NMT state stopped.

Source:
See:
  • CiA301 "Service stop remote node" (§7.2.8.2.1.3)
Parameters:
Name Type Attributes Description
nodeId number <optional>

id of node or 0 for broadcast.

Events

changeState

Description:
  • The Nmt state changed.

Source:
Type:

heartbeat

Description:
  • A consumer NMT state changed.

Source:
Properties:
Name Type Description
deviceId number

device identifier.

state NmtState

new device NMT state.

Type:
  • object

reset

Description:
  • A reset was requested.

Source:
Type:
  • boolean

timeout

Description:
  • A consumer heartbeat timed out.

Source:
Type:
  • number