CANopen implementation for Javascript
npm install canopenThis library allows the manipulation of CANopen devices as defined in CiA 301.
When updating from version 5 to version 6 be aware of the following changes:
1. Modifying the Eds via the protocol modules has been deprecated and the
preferred method is to use the new dedicated methods in the Eds class itself.
This change was made to allow configuration without needing to create
a Device object first. The following table is non-exhaustive and serves only
to illustrate the change:
Old method | New method
------------------------------- | --------------------------------
device.emcy.cobId = 0x8A | device.eds.setEmcyCobId(0x8A)
device.nmt.producerTime = 500 | device.eds.setHeartbeatProducerTime(500)
device.sdo.addServer(0x8B) | device.eds.addSdoClientParameter(0x8B)
device.sync.generate = true | device.eds.setSyncGenerationEnable(true)
2. NMT state now matters. Prior to version 6 the NMT state was available, but
not used internally. The Device object is now aware of the NMT state and will
bring up and shutdown protocol objects as the state changes. If your PDOs are
not firing after the update make sure you are calling Nmt#startNode to switch
to NmtState.OPERATIONAL. This new behavior should only take effect upon calling
Device#start().
3. Events have been refactored and moved to their respective protocol modules.
Old events are still available, but will only fire if the Device#init() method
has been called.
4. The internal Eds array of DataObjects is now keyed from the hex index rather
than the decimal index to make debug printing less confusing. A getter with the
old indexing is provided so that iterating directly on Eds.dataObjects will
still work as expected, however you should switch to using the new iterator
methods (Eds.values(), Eds.entries(), Eds.keys()).
5. SDO client/server parameters will no longer assume you want to add the
node ID if you choose 0x580/0x600 for the SDO COB-IDs. As far as I can tell this
is not officially in the standard, but was a convienence added to some other
libraries.
Pre-built documentation for the latest release is available
here.
Examples for each protocol are also available in the examples folder.
OD Entry | Description | Supported
-------- | ----------------------------- | ------------------------
0x1000 | Device type | :x:
0x1002 | Manufacturer status register | :heavy_check_mark:
0x1008 | Manufacturer device name | :heavy_check_mark:
0x1009 | Manufacturer hardware version | :heavy_check_mark:
0x100A | Manufacturer software version | :heavy_check_mark:
0x1010 | Store parameters | :x:
0x1011 | Restore default parameters | :x:
Eds provides setters for many of the communication profile objects
that are defined in CiA 301. Most of the protocol objects require one or more
entries in the Eds before they can function. Typically the user will want to
create or set those entries before calling [Device.start()][1].
[1]: https://daxbot.github.io/node-canopen/Device.html#start
OD Entry | Description | Supported
-------- | ------------------------- | ------------------------
0x1001 | Error register | :heavy_check_mark:
0x1003 | Pre-defined error field | :heavy_check_mark:
0x1014 | COB_ID EMCY | :heavy_check_mark:
0x1015 | Inhibit time EMCY | :heavy_check_mark:
0x1028 | Emergency consumer object | :heavy_check_mark:
0x1029 | Error behavior object | :x:
[2]: https://daxbot.github.io/node-canopen/Emcy.html#write
[3]: https://daxbot.github.io/node-canopen/Emcy.html#event:emergency
OD Entry | Description | Supported
-------- | ----------------------- | ------------------------
0x1018 | Identity object | :heavy_check_mark:
Supported Features:
- LSS producer :heavy_check_mark:
- LSS consumer :heavy_check_mark:
OD Entry | Description | Supported
-------- | ----------------------- | ------------------------
0x100C | Guard time | :x:
0x100D | Life time factor | :x:
0x1016 | Consumer heartbeat time | :heavy_check_mark:
0x1017 | Producer heartbeat time | :heavy_check_mark:
Supported Features:
- Remote state changes :heavy_check_mark:
- Heartbeat
- Generation :heavy_check_mark:
- Monitoring :heavy_check_mark:
- Command processing
- State changes :heavy_check_mark:
- Reset node :heavy_check_mark:
- Reset communications :heavy_check_mark:
[4]: https://daxbot.github.io/node-canopen/Nmt.html#event:changeState
[5]: https://daxbot.github.io/node-canopen/Nmt.html#event:timeout
OD Entry | Description | Supported
--------------- | ---------------------------- | ------------------
0x1400 - 0x15FF | RPDO communication parameter | :heavy_check_mark:
0x1600 - 0x17FF | RPDO mapping parameter | :heavy_check_mark:
0x1800 - 0x19FF | TPDO communication parameter | :heavy_check_mark:
0x1A00 - 0x1BFF | TPDO mapping parameter | :heavy_check_mark:
[6]: https://daxbot.github.io/node-canopen/Pdo.html#write
[7]: https://daxbot.github.io/node-canopen/Pdo.html#event:pdo
OD Entry | Description | Supported
--------------- | -------------------- | --------------------
0x1200 - 0x127F | SDO server parameter | :heavy_check_mark:
0x1280 - 0x12FF | SDO client parameter | :heavy_check_mark:
[8]: https://daxbot.github.io/node-canopen/SdoClient.html#upload
[9]: https://daxbot.github.io/node-canopen/SdoClient.html#download
OD Entry | Description | Supported
-------- | --------------------------- | -----------------------------
0x1005 | COB-ID SYNC | :heavy_check_mark:
0x1006 | Communication cycle period | :heavy_check_mark:
0x1007 | Sync window length | :x:
0x1019 | Sync counter overflow value | :heavy_check_mark:
[10]: https://daxbot.github.io/node-canopen/Sync.html#event:sync
OD Entry | Description | Supported
-------- | -------------------------- | ---------
0x1012 | COB-ID TIME | :heavy_check_mark:
0x1013 | High resolution time stamp | :x:
[11]: https://daxbot.github.io/node-canopen/Time.html#write
[12]: https://daxbot.github.io/node-canopen/Time.html#event:time