doipclient


Namedoipclient JSON
Version 1.1.4 PyPI version JSON
download
home_pagehttps://github.com/jacobschaer/python-doipclient
SummaryA Diagnostic over IP (DoIP) client implementing ISO-13400-2.
upload_time2024-11-12 06:05:31
maintainerNone
docs_urlNone
authorJacob Schaer
requires_python>=3.6
licenseNone
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": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "uds, 14229, iso-14229, diagnostic, automotive, 13400, iso-13400, doip",
    "author": "Jacob Schaer",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/01/69/71985db61f8aa7ed07e109e0aa652dec0f3413a7967fd61c1b038adab035/doipclient-1.1.4.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": null,
    "summary": "A Diagnostic over IP (DoIP) client implementing ISO-13400-2.",
    "version": "1.1.4",
    "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": "0dc6c3fe089bf9e730bde37a2375934fe295613df3da5e2b3df07d943b774a59",
                "md5": "0ce6a9b5b3657cf8e854c0cda4d77366",
                "sha256": "39d56810059bbd3025ae1aa57c596bde37dc64cf564fb33578f9a3e8146937ff"
            },
            "downloads": -1,
            "filename": "doipclient-1.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0ce6a9b5b3657cf8e854c0cda4d77366",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 19623,
            "upload_time": "2024-11-12T06:05:30",
            "upload_time_iso_8601": "2024-11-12T06:05:30.064078Z",
            "url": "https://files.pythonhosted.org/packages/0d/c6/c3fe089bf9e730bde37a2375934fe295613df3da5e2b3df07d943b774a59/doipclient-1.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "016971985db61f8aa7ed07e109e0aa652dec0f3413a7967fd61c1b038adab035",
                "md5": "4e01bcb0476519feea42b7237cd9283c",
                "sha256": "5eb74319440e4a56e1f039dfe5f7db6fe227cb1b49ed70c0511395bd09f81b4d"
            },
            "downloads": -1,
            "filename": "doipclient-1.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "4e01bcb0476519feea42b7237cd9283c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 24031,
            "upload_time": "2024-11-12T06:05:31",
            "upload_time_iso_8601": "2024-11-12T06:05:31.666170Z",
            "url": "https://files.pythonhosted.org/packages/01/69/71985db61f8aa7ed07e109e0aa652dec0f3413a7967fd61c1b038adab035/doipclient-1.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-12 06:05:31",
    "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: 1.43121s