ISO-TP for asyncio Python
=========================
This package implements ISO-TP_ over CAN as an asyncio_ transport layer,
enabling simultaneous receiving and transmitting messages with any number
of connections.
Raw CAN communication uses python-can_ which offers compatibility for many
different CAN interfaces and operating systems.
If SocketCAN `ISO-TP module`_ is loaded and Python 3.7+ is used, the transport is
delegated to the kernel if possible for better timing performance.
Use the 'socketcan' interface. If unsuccessful, raw CAN will be used as fallback.
The isotpserver from `can-utils`_ can also be used to bridge a SocketCAN ISO-TP
connection over TCP/IP.
Use the 'isotpserver' interface and 'host:port' as channel.
Why asynchronous?
-----------------
Asynchronous programming simplifies some possible use-cases:
* Full duplex receiving and transmitting on a single connection.
* Communicate on multiple connections simultaneously.
* Functional addressing where one request is sent out and all nodes respond,
then processing the responses as they arrive.
* Implementing or simulating multiple servers.
No threads need to be handled with all the locking mechanisms required by it.
Installation
------------
Install from PyPI::
$ pip install aioisotp==0.1.1
Documentation
-------------
A basic documentation can be built using Sphinx::
$ python setup.py build_sphinx
Quick start
-----------
Here is an example of an echo server implemented using a callback based
protocol and a client implemented as sequencial reader and writer streams.
.. code:: python
import asyncio
import aioisotp
class EchoServer(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
def data_received(self, data):
# Echo back the same data
self.transport.write(data)
async def main():
network = aioisotp.ISOTPNetwork('vcan0',
interface='virtual',
receive_own_messages=True)
with network.open():
# A server that uses a protocol
transport, protocol = await network.create_connection(
EchoServer, 0x1CDADCF9, 0x1CDAF9DC)
# A client that uses streams
reader, writer = await network.open_connection(
0x1CDAF9DC, 0x1CDADCF9)
writer.write(b'Hello world!')
response = await reader.read(4095)
assert response == b'Hello world!'
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
UDS
---
This package is meant to enable the use of other protocols that require
ISO-TP. One of the most common is UDS. A third party library like udsoncan_
or pyvit_ can be used to encode and decode payloads.
.. code:: python
import aioisotp
import udsoncan
...
reader, writer = await network.open_connection(0x1CDAF9DC, 0x1CDADCF9)
# Construct and send request
request = udsoncan.Request(
udsoncan.services.ReadDataByIdentifier, data=b'\xF1\x90')
writer.write(request.get_payload())
# Wait for response and decode the payload
payload = await reader.read(4095)
response = udsoncan.Response.from_payload(payload)
print(response)
print(response.data)
.. _ISO-TP: https://en.wikipedia.org/wiki/ISO_15765-2
.. _asyncio: https://docs.python.org/3/library/asyncio.html
.. _python-can: https://github.com/hardbyte/python-can
.. _udsoncan: https://github.com/pylessard/python-udsoncan
.. _pyvit: https://github.com/linklayer/pyvit
.. _ISO-TP module: https://github.com/hartkopp/can-isotp
.. _can-utils: https://github.com/linux-can/can-utils
Raw data
{
"_id": null,
"home_page": "https://github.com/christiansandberg/aioisotp",
"name": "aioisotp",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "CAN ISO-TP 15765",
"author": "Christian Sandberg",
"author_email": "christiansandberg@me.com",
"download_url": "https://files.pythonhosted.org/packages/bd/cd/09dda8536f05cd00e350e8ee217594e29fee57e495769fc4aa0fee13afba/aioisotp-0.1.1.tar.gz",
"platform": "any",
"description": "ISO-TP for asyncio Python\n=========================\n\nThis package implements ISO-TP_ over CAN as an asyncio_ transport layer,\nenabling simultaneous receiving and transmitting messages with any number\nof connections.\n\nRaw CAN communication uses python-can_ which offers compatibility for many\ndifferent CAN interfaces and operating systems.\n\nIf SocketCAN `ISO-TP module`_ is loaded and Python 3.7+ is used, the transport is\ndelegated to the kernel if possible for better timing performance.\nUse the 'socketcan' interface. If unsuccessful, raw CAN will be used as fallback.\n\nThe isotpserver from `can-utils`_ can also be used to bridge a SocketCAN ISO-TP\nconnection over TCP/IP.\nUse the 'isotpserver' interface and 'host:port' as channel.\n\n\nWhy asynchronous?\n-----------------\n\nAsynchronous programming simplifies some possible use-cases:\n\n* Full duplex receiving and transmitting on a single connection.\n* Communicate on multiple connections simultaneously.\n* Functional addressing where one request is sent out and all nodes respond,\n then processing the responses as they arrive.\n* Implementing or simulating multiple servers.\n\nNo threads need to be handled with all the locking mechanisms required by it.\n\n\nInstallation\n------------\n\nInstall from PyPI::\n\n $ pip install aioisotp==0.1.1\n\n\nDocumentation\n-------------\n\nA basic documentation can be built using Sphinx::\n\n $ python setup.py build_sphinx\n\n\nQuick start\n-----------\n\nHere is an example of an echo server implemented using a callback based\nprotocol and a client implemented as sequencial reader and writer streams.\n\n.. code:: python\n\n import asyncio\n import aioisotp\n\n\n class EchoServer(asyncio.Protocol):\n\n def connection_made(self, transport):\n self.transport = transport\n\n def data_received(self, data):\n # Echo back the same data\n self.transport.write(data)\n\n\n async def main():\n network = aioisotp.ISOTPNetwork('vcan0',\n interface='virtual',\n receive_own_messages=True)\n with network.open():\n # A server that uses a protocol\n transport, protocol = await network.create_connection(\n EchoServer, 0x1CDADCF9, 0x1CDAF9DC)\n\n # A client that uses streams\n reader, writer = await network.open_connection(\n 0x1CDAF9DC, 0x1CDADCF9)\n\n writer.write(b'Hello world!')\n response = await reader.read(4095)\n assert response == b'Hello world!'\n\n\n loop = asyncio.get_event_loop()\n loop.run_until_complete(main())\n\n\nUDS\n---\n\nThis package is meant to enable the use of other protocols that require\nISO-TP. One of the most common is UDS. A third party library like udsoncan_\nor pyvit_ can be used to encode and decode payloads.\n\n.. code:: python\n\n import aioisotp\n import udsoncan\n\n ...\n\n reader, writer = await network.open_connection(0x1CDAF9DC, 0x1CDADCF9)\n\n # Construct and send request\n request = udsoncan.Request(\n udsoncan.services.ReadDataByIdentifier, data=b'\\xF1\\x90')\n writer.write(request.get_payload())\n\n # Wait for response and decode the payload\n payload = await reader.read(4095)\n response = udsoncan.Response.from_payload(payload)\n\n print(response)\n print(response.data)\n\n\n.. _ISO-TP: https://en.wikipedia.org/wiki/ISO_15765-2\n.. _asyncio: https://docs.python.org/3/library/asyncio.html\n.. _python-can: https://github.com/hardbyte/python-can\n.. _udsoncan: https://github.com/pylessard/python-udsoncan\n.. _pyvit: https://github.com/linklayer/pyvit\n.. _ISO-TP module: https://github.com/hartkopp/can-isotp\n.. _can-utils: https://github.com/linux-can/can-utils\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Asyncio implementation of ISO-TP (ISO 15765-2)",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/christiansandberg/aioisotp"
},
"split_keywords": [
"can",
"iso-tp",
"15765"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ea38946a69888f76627b4e311b1ee3d834306245dad3d52c8916822dab8e5296",
"md5": "fb50f706373a2f038887551655bc59e3",
"sha256": "f998284978a7a41a5b527fdcf1555fe7996fd98e80b48dbe95c005df1ddf1b4a"
},
"downloads": -1,
"filename": "aioisotp-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fb50f706373a2f038887551655bc59e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 14306,
"upload_time": "2018-11-21T20:54:24",
"upload_time_iso_8601": "2018-11-21T20:54:24.206045Z",
"url": "https://files.pythonhosted.org/packages/ea/38/946a69888f76627b4e311b1ee3d834306245dad3d52c8916822dab8e5296/aioisotp-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bdcd09dda8536f05cd00e350e8ee217594e29fee57e495769fc4aa0fee13afba",
"md5": "4b3e34615e034d790906a0d6298c915a",
"sha256": "27bcffe39835e937e7be2f3374e613399d2c95631b324d292caf1f5a18f829bd"
},
"downloads": -1,
"filename": "aioisotp-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "4b3e34615e034d790906a0d6298c915a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 9711,
"upload_time": "2018-11-21T20:54:26",
"upload_time_iso_8601": "2018-11-21T20:54:26.058456Z",
"url": "https://files.pythonhosted.org/packages/bd/cd/09dda8536f05cd00e350e8ee217594e29fee57e495769fc4aa0fee13afba/aioisotp-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2018-11-21 20:54:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "christiansandberg",
"github_project": "aioisotp",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aioisotp"
}