Device

Device

A CANopen device.

This class represents a single addressable device (or node) on the bus.

Constructor

new Device(args)

Source:
Parameters:
Name Type Description
args object

arguments.

Properties
Name Type Attributes Description
eds Eds

the device's electronic data sheet.

id number <optional>

device identifier [1-127].

loopback boolean <optional>

enable loopback mode.

enableLss boolean <optional>

enable layer setting services.

Members

dataObjects :object

Description:
  • Accessor for version 5 Eds DataObjects. Do not use.

Source:
Deprecated:

Accessor for version 5 Eds DataObjects. Do not use.

Type:
  • object

emcy :Emcy

Description:
  • The Emcy module.

Source:

The Emcy module.

Type:

id :number

Description:
  • The device id.

Source:

The device id.

Type:
  • number

lss :Lss

Description:
  • The Lss module.

Source:

The Lss module.

Type:

nmt :Nmt

Description:
  • The Nmt module.

Source:

The Nmt module.

Type:

pdo :Pdo

Description:
  • The Pdo module.

Source:

The Pdo module.

Type:

sdo :SdoClient

Description:
  • The Sdo (client) module.

Source:

The Sdo (client) module.

Type:

sdoServer :SdoClient

Description:
  • The Sdo (server) module.

Source:

The Sdo (server) module.

Type:

state :NmtState

Description:
  • The Nmt state.

Source:

The Nmt state.

Type:

sync :Sync

Description:
  • The Sync module.

Source:

The Sync module.

Type:

time :Time

Description:
  • The Time module.

Source:

The Time module.

Type:

Methods

getRaw(index) → {Buffer}

Description:
  • Get the raw value of an EDS entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

Returns:

entry data.

Type
Buffer

getRawArray(index, subIndex) → {Buffer}

Description:
  • Get the raw value of an EDS sub-entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

subIndex number

sub-object index.

Returns:

entry data.

Type
Buffer

getScale(index) → {number|bigint|string|Date}

Description:
  • Get the scale factor of an EDS entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

Returns:

entry value.

Type
number | bigint | string | Date

getScaleArray(index, subIndex) → {number|bigint|string|Date}

Description:
  • Get the scale factor of an EDS sub-entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

subIndex number

sub-object index.

Returns:

entry value.

Type
number | bigint | string | Date

getValue(index) → {number|bigint|string|Date}

Description:
  • Get the value of an EDS entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

Returns:

entry value.

Type
number | bigint | string | Date

getValueArray(index, subIndex) → {number|bigint|string|Date}

Description:
  • Get the value of an EDS sub-entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

subIndex number

sub-object index.

Returns:

entry value.

Type
number | bigint | string | Date

init()

Description:
  • Initialize the device and audit the object dictionary. Additionally this method will enable deprecated Device level events.

Source:
Deprecated:

mapRemoteNode(args)

Description:
  • Map a remote node's EDS file on to this Device.

    This method provides an easy way to set up communication with another device. Most EDS transmit/producer entries will be mapped to their local receive/consumer analogues. Note that this method will heavily modify the Device's internal EDS file.

    This may be called multiple times to map more than one EDS.

Source:
Since:
  • 6.0.0
Parameters:
Name Type Description
args object

method arguments.

Properties
Name Type Attributes Description
id number

the remote node's CAN identifier.

eds Eds | string

the server's EDS.

dataStart number <optional>

start index for SDO entries.

skipEmcy boolean <optional>

Skip EMCY producer -> consumer.

skipNmt boolean <optional>

Skip NMT producer -> consumer.

skipPdo boolean <optional>

Skip PDO transmit -> receive.

skipSdo boolean <optional>

Skip SDO server -> client.

receive(message)

Description:
  • Call with each incoming CAN message.

Source:
Parameters:
Name Type Description
message object

CAN frame.

Properties
Name Type Description
id number

CAN message identifier.

data Buffer

CAN message data;

len number

CAN message length in bytes.

setRaw(index, raw)

Description:
  • Set the raw value of an EDS entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

raw Buffer

raw Buffer to set.

setRawArray(index, subIndex, raw)

Description:
  • Set the raw value of an EDS sub-entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

subIndex number

sub-object index.

raw Buffer

raw Buffer to set.

setScale(index, scaleFactor)

Description:
  • Set the scale factor of an EDS entry.

Source:
Since:
  • 6.0.0
Parameters:
Name Type Description
index number | string

index or name of the entry.

scaleFactor number

value to set.

setScaleArray(index, subIndex, scaleFactor)

Description:
  • Set the scale factor of an EDS sub-entry.

Source:
Since:
  • 6.0.0
Parameters:
Name Type Description
index number | string

index or name of the entry.

subIndex number

array sub-index to set;

scaleFactor number

value to set.

setTransmitFunction(send)

Description:
  • Set the send function.

    This method has been deprecated. Add a listener for the 'message' event instead.

Source:
Deprecated:
Parameters:
Name Type Description
send function

send function.

setValue(index, value)

Description:
  • Set the value of an EDS entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

value number | bigint | string | Date

value to set.

setValueArray(index, subIndex, value)

Description:
  • Set the value of an EDS sub-entry.

Source:
Parameters:
Name Type Description
index number | string

index or name of the entry.

subIndex number

array sub-index to set;

value number | bigint | string | Date

value to set.

start()

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

Source:
Since:
  • 6.0.0

stop()

Description:
  • Cleanup timers and shutdown the device.

Source:
Since:
  • 6.0.0

Events

emergency

Description:
  • Emcy object consumed (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

lssChangeDeviceId

Description:
  • Change of device id (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

lssChangeMode

Description:
  • Change of LSS mode (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

nmtChangeState

Description:
  • NMT state changed (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

nmtChangeState

Description:
  • NMT consumer timeout (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

nmtResetCommunication

Description:
  • NMT reset communication (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

nmtResetNode

Description:
  • NMT reset node (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

pdo

Description:
  • PDO received (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

sync

Description:
  • Sync object consumed (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated:

time

Description:
  • Time object consumed (deprecated).

    This event needs to be enabled by calling Device#init before it will fire.

Source:
Deprecated: