Skip to main content

A package to interface with UDS via different CAN interfaces

Project description

uds_connect

uds_connect is a Python package for interacting with UDS (Unified Diagnostic Services) over various CAN interfaces, such as peak, kvaser, and vector.

Installation

pip install uds_connect

Example Usage

from uds_connect import initialize_uds, send_with_retry

# Define the driver type, request ID, and response ID
driver_type = "kvaser"  # Options: 'peak', 'kvaser', 'vector'
request_id = 0x7D2
response_id = 0x7D3

# Additional parameters based on the driver type
additional_params = {
    # "device": "PCAN_USBBUS1",  # For 'peak' driver
    "channel": 0,               # For 'kvaser' or 'vector' drivers
    "bitrate": 500000,          # For 'kvaser' driver
    # "app_name": "BALCAN"       # For 'vector' driver
}

# Initialize the UDS instance with the specified configuration
uds_instance = initialize_uds(driver_type, request_id, response_id, **additional_params)

# UDS requests
vin_number = send_with_retry(uds_instance, [0x22, 0xF1, 0x90])
hex_file = send_with_retry(uds_instance, [0x22, 0xF1, 0x11])
assembly_part_num = send_with_retry(uds_instance, [0x22, 0xF1, 0x87])
hw_serial_number = send_with_retry(uds_instance, [0x22, 0xF1, 0x8C])

# Format responses by removing the first three bytes (header)
formatted_vin = vin_number[3:]
formatted_hex = hex_file[3:]
formatted_assembly_num = assembly_part_num[3:]
formatted_hw_serial_num = hw_serial_number[3:]

# Convert byte data to a readable string format
result_vin = ''.join(chr(num) for num in formatted_vin)
result_hex = ''.join(chr(num) for num in formatted_hex)
result_assembly_num = ''.join(chr(num) for num in formatted_assembly_num)
result_serial_num = ''.join(chr(num) for num in formatted_hw_serial_num)

# Collect vehicle data in a dictionary
vehicle_data = {
    'vin_number': result_vin,
    'hex_file_name': result_hex,
    'assembly_part_number': result_assembly_num,
    'hw_serial_number': result_serial_num
}

print(vehicle_data)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uds_connect-0.1.5.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uds_connect-0.1.5-py3-none-any.whl (92.4 kB view details)

Uploaded Python 3

File details

Details for the file uds_connect-0.1.5.tar.gz.

File metadata

  • Download URL: uds_connect-0.1.5.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for uds_connect-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e5e7a3faccc10e636afc208d6e9135ca5b408f45db2611e730369a77fe44b9fb
MD5 beddf8f824d9b129869940aa22fd0ef0
BLAKE2b-256 df97f15dc4f80e8a76a05f94ee61fc56c7606959c44b0ff6fcccf62b202f6541

See more details on using hashes here.

File details

Details for the file uds_connect-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: uds_connect-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 92.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for uds_connect-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dc2ac5e94486fbc945cbbacdc3fcbcbbf10fedb11980d311d0a3d52624ec8235
MD5 3a0256be15b5d5645b3ef29cf861fb40
BLAKE2b-256 8299dc66a74a048745747d83a43833bae06eacf6673ef9897b1994a7b40b4602

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page