doipclient


Namedoipclient JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://github.com/jacobschaer/python-doipclient
SummaryA Diagnostic over IP (DoIP) client implementing ISO-13400-2.
upload_time2023-08-27 20:15:46
maintainer
docs_urlNone
authorJacob Schaer
requires_python>=3.6
license
keywords uds 14229 iso-14229 diagnostic automotive 13400 iso-13400 doip
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            python-doipclient
#################

.. image:: https://github.com/jacobschaer/python-doipclient/actions/workflows/tests.yml/badge.svg?branch=main

doipclient is a pure Python 3 Diagnostic over IP (DoIP) client which can be used
for communicating with modern ECU's over automotive ethernet. It implements the
majority of ISO-13400 (2019) from the perspective of a short-lived synchronous
client. The primary use case is to serve as a transport layer implementation for
the `udsoncan <https://github.com/pylessard/python-udsoncan>`_ library. The code
is published under MIT license on GitHub (jacobschaer/python-doipclient).

Documentation
-------------

The documentation is available here : https://python-doipclient.readthedocs.io/

Requirements
------------

 - Python 3.6+

Installation
------------

using pip::

    pip install doipclient

Running Tests from source
-------------------------

using pytest::

    pip install pytest pytest-mock
    pytest

Example
-------
Updated version of udsoncan's example using `python_doip` instead of IsoTPSocketConnection

.. code-block:: python

   import SomeLib.SomeCar.SomeModel as MyCar

   import udsoncan
   from doipclient import DoIPClient
   from doipclient.connectors import DoIPClientUDSConnector
   from udsoncan.client import Client
   from udsoncan.exceptions import *
   from udsoncan.services import *
   
   udsoncan.setup_logging()
   
   ecu_ip = '127.0.0.1'
   ecu_logical_address = 0x00E0
   doip_client = DoIPClient(ecu_ip, ecu_logical_address)
   conn = DoIPClientUDSConnector(doip_client)
   with Client(conn, request_timeout=2, config=MyCar.config) as client:
      try:
         client.change_session(DiagnosticSessionControl.Session.extendedDiagnosticSession)  # integer with value of 3
         client.unlock_security_access(MyCar.debug_level)                                   # Fictive security level. Integer coming from fictive lib, let's say its value is 5
         client.write_data_by_identifier(udsoncan.DataIdentifier.VIN, 'ABC123456789')       # Standard ID for VIN is 0xF190. Codec is set in the client configuration
         print('Vehicle Identification Number successfully changed.')
         client.ecu_reset(ECUReset.ResetType.hardReset)                                     # HardReset = 0x01
      except NegativeResponseException as e:
         print('Server refused our request for service %s with code "%s" (0x%02x)' % (e.response.service.get_name(), e.response.code_name, e.response.code))
      except (InvalidResponseException, UnexpectedResponseException) as e:
         print('Server sent an invalid payload : %s' % e.response.original_payload)

      # Because we reset our UDS server, we must also reconnect/reactivate the DoIP socket
      # Alternatively, we could have used the auto_reconnect_tcp flag on the DoIPClient
      # Note: ECU's do not restart instantly, so you may need a sleep() before moving on
      doip_client.reconnect()
      client.tester_present()

   # Cleanup the DoIP Socket when we're done. Alternatively, we could have used the
   # close_connection flag on conn so that the udsoncan client would clean it up
   doip_client.close()

python-uds Support
------------------
The `python-uds <https://github.com/richClubb/python-uds>`_ can also be used
but requires a fork until the owner merges this PR
`Doip #63 <https://github.com/richClubb/python-uds/pull/63>`_. For now, to use
the port:

using pip::

    git clone https://github.com/jacobschaer/python-uds
    git checkout doip
    cd python-uds
    pip install .

Example:

.. code-block:: python

   from uds import Uds

   ecu = Uds(transportProtocol="DoIP", ecu_ip="192.168.1.1", ecu_logical_address=1)
   try:
       response = ecu.send([0x3E, 0x00])
       print(response)  # This should be [0x7E, 0x00]
   except:
       print("Send did not complete")

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jacobschaer/python-doipclient",
    "name": "doipclient",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "uds,14229,iso-14229,diagnostic,automotive,13400,iso-13400,doip",
    "author": "Jacob Schaer",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/9d/22/59fdfc934c4117cd7b9e2341ca629b4a5614f1f3f564c128630fff350290/doipclient-1.1.1.tar.gz",
    "platform": null,
    "description": "python-doipclient\r\n#################\r\n\r\n.. image:: https://github.com/jacobschaer/python-doipclient/actions/workflows/tests.yml/badge.svg?branch=main\r\n\r\ndoipclient is a pure Python 3 Diagnostic over IP (DoIP) client which can be used\r\nfor communicating with modern ECU's over automotive ethernet. It implements the\r\nmajority of ISO-13400 (2019) from the perspective of a short-lived synchronous\r\nclient. The primary use case is to serve as a transport layer implementation for\r\nthe `udsoncan <https://github.com/pylessard/python-udsoncan>`_ library. The code\r\nis published under MIT license on GitHub (jacobschaer/python-doipclient).\r\n\r\nDocumentation\r\n-------------\r\n\r\nThe documentation is available here : https://python-doipclient.readthedocs.io/\r\n\r\nRequirements\r\n------------\r\n\r\n - Python 3.6+\r\n\r\nInstallation\r\n------------\r\n\r\nusing pip::\r\n\r\n    pip install doipclient\r\n\r\nRunning Tests from source\r\n-------------------------\r\n\r\nusing pytest::\r\n\r\n    pip install pytest pytest-mock\r\n    pytest\r\n\r\nExample\r\n-------\r\nUpdated version of udsoncan's example using `python_doip` instead of IsoTPSocketConnection\r\n\r\n.. code-block:: python\r\n\r\n   import SomeLib.SomeCar.SomeModel as MyCar\r\n\r\n   import udsoncan\r\n   from doipclient import DoIPClient\r\n   from doipclient.connectors import DoIPClientUDSConnector\r\n   from udsoncan.client import Client\r\n   from udsoncan.exceptions import *\r\n   from udsoncan.services import *\r\n   \r\n   udsoncan.setup_logging()\r\n   \r\n   ecu_ip = '127.0.0.1'\r\n   ecu_logical_address = 0x00E0\r\n   doip_client = DoIPClient(ecu_ip, ecu_logical_address)\r\n   conn = DoIPClientUDSConnector(doip_client)\r\n   with Client(conn, request_timeout=2, config=MyCar.config) as client:\r\n      try:\r\n         client.change_session(DiagnosticSessionControl.Session.extendedDiagnosticSession)  # integer with value of 3\r\n         client.unlock_security_access(MyCar.debug_level)                                   # Fictive security level. Integer coming from fictive lib, let's say its value is 5\r\n         client.write_data_by_identifier(udsoncan.DataIdentifier.VIN, 'ABC123456789')       # Standard ID for VIN is 0xF190. Codec is set in the client configuration\r\n         print('Vehicle Identification Number successfully changed.')\r\n         client.ecu_reset(ECUReset.ResetType.hardReset)                                     # HardReset = 0x01\r\n      except NegativeResponseException as e:\r\n         print('Server refused our request for service %s with code \"%s\" (0x%02x)' % (e.response.service.get_name(), e.response.code_name, e.response.code))\r\n      except (InvalidResponseException, UnexpectedResponseException) as e:\r\n         print('Server sent an invalid payload : %s' % e.response.original_payload)\r\n\r\n      # Because we reset our UDS server, we must also reconnect/reactivate the DoIP socket\r\n      # Alternatively, we could have used the auto_reconnect_tcp flag on the DoIPClient\r\n      # Note: ECU's do not restart instantly, so you may need a sleep() before moving on\r\n      doip_client.reconnect()\r\n      client.tester_present()\r\n\r\n   # Cleanup the DoIP Socket when we're done. Alternatively, we could have used the\r\n   # close_connection flag on conn so that the udsoncan client would clean it up\r\n   doip_client.close()\r\n\r\npython-uds Support\r\n------------------\r\nThe `python-uds <https://github.com/richClubb/python-uds>`_ can also be used\r\nbut requires a fork until the owner merges this PR\r\n`Doip #63 <https://github.com/richClubb/python-uds/pull/63>`_. For now, to use\r\nthe port:\r\n\r\nusing pip::\r\n\r\n    git clone https://github.com/jacobschaer/python-uds\r\n    git checkout doip\r\n    cd python-uds\r\n    pip install .\r\n\r\nExample:\r\n\r\n.. code-block:: python\r\n\r\n   from uds import Uds\r\n\r\n   ecu = Uds(transportProtocol=\"DoIP\", ecu_ip=\"192.168.1.1\", ecu_logical_address=1)\r\n   try:\r\n       response = ecu.send([0x3E, 0x00])\r\n       print(response)  # This should be [0x7E, 0x00]\r\n   except:\r\n       print(\"Send did not complete\")\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Diagnostic over IP (DoIP) client implementing ISO-13400-2.",
    "version": "1.1.1",
    "project_urls": {
        "Homepage": "https://github.com/jacobschaer/python-doipclient"
    },
    "split_keywords": [
        "uds",
        "14229",
        "iso-14229",
        "diagnostic",
        "automotive",
        "13400",
        "iso-13400",
        "doip"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f31df3747d76c658b87a41dc3a271f6ce8951cd0f601e99c9bca8b97b86588d1",
                "md5": "80b9b26313417efe38a849db76cb9d1f",
                "sha256": "753b648115e9c28b5c57e72b8b700e34b65c296f770925b6673fc9bd7d17375c"
            },
            "downloads": -1,
            "filename": "doipclient-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "80b9b26313417efe38a849db76cb9d1f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 23828,
            "upload_time": "2023-08-27T20:15:44",
            "upload_time_iso_8601": "2023-08-27T20:15:44.828455Z",
            "url": "https://files.pythonhosted.org/packages/f3/1d/f3747d76c658b87a41dc3a271f6ce8951cd0f601e99c9bca8b97b86588d1/doipclient-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d2259fdfc934c4117cd7b9e2341ca629b4a5614f1f3f564c128630fff350290",
                "md5": "3479957c6d15a8fa215a225f87fabf5b",
                "sha256": "53d02d941f13d77fb0ad83e2e01f1063e2c1be26f495710e9a255c0fad045b86"
            },
            "downloads": -1,
            "filename": "doipclient-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3479957c6d15a8fa215a225f87fabf5b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 23895,
            "upload_time": "2023-08-27T20:15:46",
            "upload_time_iso_8601": "2023-08-27T20:15:46.034997Z",
            "url": "https://files.pythonhosted.org/packages/9d/22/59fdfc934c4117cd7b9e2341ca629b4a5614f1f3f564c128630fff350290/doipclient-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-27 20:15:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jacobschaer",
    "github_project": "python-doipclient",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "doipclient"
}
        
Elapsed time: 0.11403s