实施用于汽车行业的统一诊断服务 (UDS) 协议 (ISO-14229)。
项目描述
python-udsoncan
该项目是使用 Python 3 编写的 ISO-14229 定义的统一诊断服务 (UDS) 协议的实现。代码在 GitHub (pylessard/python-udsoncan) 上根据 MIT 许可发布。
文档
该文档可在此处获得: http: //udsoncan.readthedocs.io
要求
蟒蛇 3+
安装
使用点子:
pip install udsoncan
例子
import SomeLib.SomeCar.SomeModel as MyCar
import udsoncan
from udsoncan.connections import IsoTPSocketConnection
from udsoncan.client import Client
from udsoncan.exceptions import *
from udsoncan.services import *
udsoncan.setup_logging()
conn = IsoTPSocketConnection('can0', rxid=0x123, txid=0x456)
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)
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
udsoncan-1.15.tar.gz
(103.3 kB
查看哈希)
内置分布
udsoncan-1.15-py3-none-any.whl
(134.9 kB
查看哈希)