{"id":17322043,"url":"https://github.com/christiansandberg/canopen","last_synced_at":"2025-04-03T01:02:52.905Z","repository":{"id":37336744,"uuid":"68737600","full_name":"christiansandberg/canopen","owner":"christiansandberg","description":"CANopen for Python","archived":false,"fork":false,"pushed_at":"2024-10-18T07:25:33.000Z","size":769,"stargazers_count":443,"open_issues_count":59,"forks_count":197,"subscribers_count":30,"default_branch":"master","last_synced_at":"2024-10-29T15:13:07.753Z","etag":null,"topics":["can","canopen","python"],"latest_commit_sha":null,"homepage":"http://canopen.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christiansandberg.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-20T17:42:18.000Z","updated_at":"2024-10-24T03:32:24.000Z","dependencies_parsed_at":"2023-11-14T21:31:26.497Z","dependency_job_id":"f0ad7227-1aab-4010-bfbd-cc81bab3a670","html_url":"https://github.com/christiansandberg/canopen","commit_stats":{"total_commits":473,"total_committers":62,"mean_commits":7.629032258064516,"dds":0.4947145877378436,"last_synced_commit":"64772dc45cfdfd924f6de0bb6d58b66a5d0c1fba"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiansandberg%2Fcanopen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiansandberg%2Fcanopen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiansandberg%2Fcanopen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiansandberg%2Fcanopen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christiansandberg","download_url":"https://codeload.github.com/christiansandberg/canopen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246916749,"owners_count":20854513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["can","canopen","python"],"created_at":"2024-10-15T13:40:47.953Z","updated_at":"2025-04-03T01:02:52.885Z","avatar_url":"https://github.com/christiansandberg.png","language":"Python","funding_links":[],"categories":["Network and Middleware"],"sub_categories":["Controller Area Network"],"readme":"CANopen for Python\n==================\n\nA Python implementation of the CANopen_ standard.\nThe aim of the project is to support the most common parts of the CiA 301\nstandard in a simple Pythonic interface. It is mainly targeted for testing and\nautomation tasks rather than a standard compliant master implementation.\n\nThe library supports Python 3.8 or newer.\n\n\nFeatures\n--------\n\nThe library is mainly meant to be used as a master.\n\n* NMT master\n* SDO client\n* PDO producer/consumer\n* SYNC producer\n* EMCY consumer\n* TIME producer\n* LSS master\n* Object Dictionary from EDS\n* 402 profile support\n\nIncomplete support for creating slave nodes also exists.\n\n* SDO server\n* PDO producer/consumer\n* NMT slave\n* EMCY producer\n* Object Dictionary from EDS\n\n\nInstallation\n------------\n\nInstall from PyPI_ using :program:`pip`::\n\n    $ pip install canopen\n\nInstall from latest ``master`` on GitHub::\n\n    $ pip install https://github.com/christiansandberg/canopen/archive/master.zip\n\nIf you want to be able to change the code while using it, clone it then install\nit in `develop mode`_::\n\n    $ git clone https://github.com/christiansandberg/canopen.git\n    $ cd canopen\n    $ pip install -e .\n\nUnit tests can be run using the pytest_ framework::\n\n    $ pip install -r requirements-dev.txt\n    $ pytest -v\n\nYou can also use :mod:`unittest` standard library module::\n\n    $ python3 -m unittest discover test -v\n\nDocumentation\n-------------\n\nDocumentation can be found on Read the Docs:\n\nhttp://canopen.readthedocs.io/en/latest/\n\nIt can also be generated from a local clone using Sphinx_::\n\n    $ pip install -r doc/requirements.txt\n    $ make -C doc html\n\n\nHardware support\n----------------\n\nThis library supports multiple hardware and drivers through the python-can_ package.\nSee `the list of supported devices \u003chttps://python-can.readthedocs.io/en/stable/configuration.html#interface-names\u003e`_.\n\nIt is also possible to integrate this library with a custom backend.\n\n\nQuick start\n-----------\n\nHere are some quick examples of what you can do:\n\nThe PDOs can be access by three forms:\n\n**1st:** :code:`node.tpdo[n]` or :code:`node.rpdo[n]`\n\n**2nd:** :code:`node.pdo.tx[n]` or :code:`node.pdo.rx[n]`\n\n**3rd:** :code:`node.pdo[0x1A00]` or :code:`node.pdo[0x1600]`\n\nThe :code:`n` is the PDO index (normally 1 to 4). The second form of access is for backward compatibility.\n\n.. code-block:: python\n\n    import canopen\n\n    # Start with creating a network representing one CAN bus\n    network = canopen.Network()\n\n    # Add some nodes with corresponding Object Dictionaries\n    node = canopen.RemoteNode(6, '/path/to/object_dictionary.eds')\n    network.add_node(node)\n\n    # Connect to the CAN bus\n    # Arguments are passed to python-can's can.Bus() constructor\n    # (see https://python-can.readthedocs.io/en/latest/bus.html).\n    network.connect()\n    # network.connect(interface='socketcan', channel='can0')\n    # network.connect(interface='kvaser', channel=0, bitrate=250000)\n    # network.connect(interface='pcan', channel='PCAN_USBBUS1', bitrate=250000)\n    # network.connect(interface='ixxat', channel=0, bitrate=250000)\n    # network.connect(interface='vector', app_name='CANalyzer', channel=0, bitrate=250000)\n    # network.connect(interface='nican', channel='CAN0', bitrate=250000)\n\n    # Read a variable using SDO\n    device_name = node.sdo['Manufacturer device name'].raw\n    vendor_id = node.sdo[0x1018][1].raw\n\n    # Write a variable using SDO\n    node.sdo['Producer heartbeat time'].raw = 1000\n\n    # Read PDO configuration from node\n    node.tpdo.read()\n    node.rpdo.read()\n    # Re-map TPDO[1]\n    node.tpdo[1].clear()\n    node.tpdo[1].add_variable('Statusword')\n    node.tpdo[1].add_variable('Velocity actual value')\n    node.tpdo[1].add_variable('Some group', 'Some subindex')\n    node.tpdo[1].trans_type = 254\n    node.tpdo[1].event_timer = 10\n    node.tpdo[1].enabled = True\n    # Save new PDO configuration to node\n    node.tpdo[1].save()\n\n    # Transmit SYNC every 100 ms\n    network.sync.start(0.1)\n\n    # Change state to operational (NMT start)\n    node.nmt.state = 'OPERATIONAL'\n\n    # Read a value from TPDO[1]\n    node.tpdo[1].wait_for_reception()\n    speed = node.tpdo[1]['Velocity actual value'].phys\n    val = node.tpdo['Some group.Some subindex'].raw\n\n    # Disconnect from CAN bus\n    network.sync.stop()\n    network.disconnect()\n\n\nDebugging\n---------\n\nIf you need to see what's going on in better detail, you can increase the\nlogging_ level:\n\n.. code-block:: python\n\n    import logging\n    logging.basicConfig(level=logging.DEBUG)\n\n\n.. _PyPI: https://pypi.org/project/canopen/\n.. _CANopen: https://www.can-cia.org/canopen/\n.. _python-can: https://python-can.readthedocs.org/en/stable/\n.. _Sphinx: http://www.sphinx-doc.org/\n.. _develop mode: https://packaging.python.org/distributing/#working-in-development-mode\n.. _logging: https://docs.python.org/3/library/logging.html\n.. _pytest: https://docs.pytest.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristiansandberg%2Fcanopen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristiansandberg%2Fcanopen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristiansandberg%2Fcanopen/lists"}