
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
A CANopen library to implement responder nodes.
Backends:
.. header
.. _pytest: https://docs.pytest.org/en/latest .. _Black: https://black.readthedocs.io/en/stable/ .. _mypy: http://mypy-lang.org/ .. _Pylint: https://www.pylint.org/ .. _Sphinx: http://www.sphinx-doc.org .. _GitHub.com: https://github.com/semiversus/python-durand .. _CiA301: http://can-cia.org/standardization/technical-documents
Object Dictionary:
EDS Support:
SDO Servers:
PDO Support:
EMCY Producer Service:
Heartbeat Producer Service:
NMT Slave Service:
SYNC Consumer Service:
CiA305 Layer Setting Service:
CAN Interface Abstraction:
Scheduling:
TODO:
Creating a Node:
.. code-block:: python
import can
from durand import CANBusNetwork, Node, Variable, Record, DatatypeEnum
bus = can.Bus(bustype='socketcan', channel='vcan0')
network = CANBusNetwork(bus)
node = Node(network, node_id=0x01)
Congratulations! You now have a CiA-301 compliant node running. The Layer Setting Service is also supported out of the box.
Adding Objects:
.. code-block:: python
od = node.object_dictionary
# Add variable at index 0x2000
od[0x2000] = Variable(DatatypeEnum.UNSIGNED16, access='rw', value=10, name='Parameter 1')
# Add record at index 0x2001
record = Record(name='Parameter Record')
record[1] = Variable(DatatypeEnum.UNSIGNED8, access='ro', value=0, name='Parameter 2a')
record[2] = Variable(DatatypeEnum.REAL32, access='rw', value=0, name='Parameter 2b')
od[0x2001] = record
Accessing Values:
The objects can be read and written directly by accessing the object dictionary:
.. code-block:: python
print(f'Value of Parameter 1: {od.read(0x2000, 0)}')
od.write(0x2001, 1, value=0xAA)
Adding Callbacks:
A more event-driven approach is to use callbacks. The following callbacks are available:
validate_callbacks
: Called before a value in the object dictionary is updatedupdate_callbacks
: Called when the value has been changed (via od.write
or via CAN bus)download_callbacks
: Called when the value has been changed via CAN busread_callback
: Called when an object is read (return value is used).. code-block:: python
od.validate_callbacks[(0x2000, 0)].add(lambda v: v % 2 == 0)
od.update_callbacks[(0x2001, 2)].add(lambda v: print(f'Update for Parameter 2b: {v}'))
od.download_callbacks[(0x2000, 0)].add(lambda v: print(f'Download for Parameter 1: {v}'))
od.set_read_callback(0x2001, 1, lambda: 17)
PDO Mapping:
PDOs can be dynamically mapped via the SDO server or programmatically. The PDO indices start at 0.
.. code-block:: python
node.tpdo[0].mapping = [(0x2001, 1), (0x2001, 2)]
node.tpdo[0].transmission_type = 1 # Transmit on every SYNC
node.rpdo[0].mapping = [(0x2000, 0)]
node.tpdo[0].transmission_type = 255 # Event-driven (processed when received)
.. code-block:: bash
pip install durand
This library would not be possible without:
.. _python-canopen: https://github.com/christiansandberg/canopen .. _python-can: https://github.com/hardbyte/python-can
FAQs
CANopen library providing functionality to implement responder nodes
We found that durand demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.