Skip to content

Repository files navigation

🔓 ECUUNLOCK

WebsiteYouTube


 ██╗██████╗ ███████╗██████╗ ██╗ ██╗ █████╗ ██████╗ ██╗
██║╚════██╗██╔════╝╚════██╗██║ ██║ ██╔══██╗██╔══██╗██║
██║ █████╔╝███████╗ █████╔╝███████║█████╗███████║██████╔╝██║
██ ██║██╔═══╝ ╚════██║ ╚═══██╗╚════██║╚════╝██╔══██║██╔═══╝ ██║
╚█████╔╝███████╗███████║██████╔╝ ██║ ██║ ██║██║ ██║
╚════╝ ╚══════╝╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝

A Comprehensive Python Library for SAE J2534 PassThru Vehicle Diagnostics

Developed by ECUUNLOCK - Vehicle ECU Programming & Security Research

License: MITPython 3.10+WindowsSAE J2534TypedProtocols

Quick StartInstallationDocumentationContributing


📋 Table of Contents

✨ Features

  • Complete SAE J2534-1 Implementation - Full support for PassThru API v04.04
  • 🎯 High-Level Interface - Simple, Pythonic API for vehicle diagnostics
  • 🔍 Auto-Discovery - Automatically find and connect to J2534 devices
  • 📡 Multi-Protocol Support - CAN, ISO15765, J1850 VPW/PWM, ISO9141, ISO14230, SCI
  • 🐛 Debug Modes - Built-in debug logging with hex dump utilities
  • ⚠️Exception Handling - Optional exception mode for detailed error info
  • 🎨 GUI Examples - 4 complete GUI frameworks demonstrated
  • 📝 Type Hints - Full type annotations for IDE support
  • 📦 pip Installable - Easy installation with optional dependencies

📦 Installation

From PyPI (Recommended)

# Basic installation
pip install j2534-api
# With GUI support (choose your framework)
pip install j2534-api[gui-pyqt5]
pip install j2534-api[gui-customtkinter]
pip install j2534-api[gui-all] # All GUI frameworks

From Source

git clone https://github.com/keenanlaws/j2534-api.git
cd j2534-api
pip install -e .

📋 Requirements

RequirementDetails
Python3.10 or higher (32-bit recommended for J2534 DLL compatibility)
OSWindows only (uses Windows Registry and DLLs)
HardwareAny SAE J2534-1 compliant PassThru device

Note

32-bit Python is recommended because most J2534 device DLLs are 32-bit. Using 64-bit Python may cause DLL loading failures.

Supported Devices

ManufacturerDevices
Drew TechnologiesMongoose Pro, CarDAQ-Plus 3
FordVCM II
General MotorsMDI, MDI 2
HondaHDS
ToyotaTechstream
BoschKTS Series
And more...Any J2534-1 compliant device

🚀 Quick Start

List Available Devices

fromJ2534_REGISTRYimportget_all_j2534_devicesdevices=get_all_j2534_devices()
fordeviceindevices:
print(f"{device.name} - {device.vendor}")
print(f" DLL: {device.function_library_path}")
print(f" Protocols: {', '.join(device.supported_protocols)}")

Auto-Connect to Vehicle

fromAutoJ2534importj2534_communication# Automatically find device and connect to vehicleresult=j2534_communication.auto_connect()
ifresult:
tool_index, connection_key, key_name, device_name, firmware_version, dll_version=resultprint(f"Connected to {device_name}")
print(f"Firmware: {firmware_version}")
print(f"DLL: {dll_version}")
# Send a diagnostic message (TesterPresent)response=j2534_communication.transmit_and_receive_message([0x3E, 0x00])
print(f"ECU Response: {response}")
# Clean upj2534_communication.disconnect()
j2534_communication.close()
📖 More Examples

Manual Connection with Configuration

fromAutoJ2534importj2534_communication, Connections# List available devicesj2534_communication.numbered_tool_list()
# Connect to device 0 with Chrysler PCM configurationifj2534_communication.open_communication(device_index=0, connection_name="chrys1"):
# Get device infoinfo=j2534_communication.tool_info()
print(f"Device: {info[0]}, FW: {info[1]}, DLL: {info[2]}")
# Check battery voltagevoltage=j2534_communication.check_volts()
print(f"Battery: {voltage:.2f}V")
# Send diagnostic requestresponse=j2534_communication.transmit_and_receive_message([0x10, 0x01])
print(f"Response: {response}")
# Disconnectj2534_communication.disconnect()
j2534_communication.close()

Low-Level API Access

fromJ2534import (
pt_open, pt_close, pt_connect, pt_disconnect,
pt_read_message, pt_write_message, pt_start_ecu_filter,
set_j2534_device_to_connect, get_list_j2534_devices,
ProtocolId, BaudRate, TxFlags, PassThruMsgBuilder,
j2534_config
)
# Enable debug loggingj2534_config.enable_debug()
# Enable exception mode (raises exceptions on errors)j2534_config.enable_exceptions()
# List and select devicedevices=get_list_j2534_devices()
print(f"Found {len(devices)} devices")
set_j2534_device_to_connect(0)
# Open devicedevice_id=pt_open()
# Connect with ISO15765 protocolchannel_id=pt_connect(
device_id=device_id,
protocol_id=ProtocolId.ISO15765,
flags=0,
baud_rate=BaudRate.CAN_500K
)
# Set up flow control filter (required for ISO15765)filter_id=pt_start_ecu_filter(
channel_id=channel_id,
protocol_id=ProtocolId.ISO15765,
mask_identifier=0xFFFFFFFF,
pattern_identifier=0x7E8, # ECU response IDflow_control_identifier=0x7E0# Tester request ID
)
# Create and send a messagetx_msg=PassThruMsgBuilder(ProtocolId.ISO15765, TxFlags.ISO15765_FRAME_PAD)
tx_msg.set_identifier_and_data(0x7E0, [0x3E, 0x00]) # TesterPresentpt_write_message(channel_id, tx_msg, 1, 1000)
# Read responserx_msg=PassThruMsgBuilder(ProtocolId.ISO15765, 0)
ifpt_read_message(channel_id, rx_msg, 1, 2000) ==0:
print(f"Response: {rx_msg.dump_output()}")
# Clean uppt_disconnect(channel_id)
pt_close(device_id)

📡 Protocol Support

ProtocolIDBaud RateUse Case
ISO 157656500KModern CAN diagnostics (OBD-II 2008+)
CAN5125K-500KRaw CAN bus access, J1939
J1850 VPW110.4KGM vehicles (pre-2008)
J1850 PWM241.6KFord vehicles (pre-2008)
ISO 9141310.4KK-Line (older European/Asian)
ISO 14230410.4KKWP2000 (European vehicles)
SCI7-107.8K-62.5KChrysler/Stellantis proprietary

Tip

For ISO15765 (CAN diagnostics), a flow control filter is required. Use pt_start_ecu_filter() to set it up.


🏗️ Architecture

graph TD
A[Your Python App] --> B[AutoJ2534<br/>High-Level API]
A --> C[J2534<br/>Low-Level API]
B --> C
C --> D[DLL Interface<br/>ctypes bindings]
D --> E[J2534 PassThru Device<br/>Mongoose, VCM II, etc.]
E --> F[Vehicle ECU<br/>via OBD-II/CAN]
G[J2534_REGISTRY] --> C
G -.-> |Device Discovery| D
style A fill:#e1f5fe
style B fill:#fff3e0
style C fill:#fff3e0
style D fill:#f3e5f5
style E fill:#e8f5e9
style F fill:#ffebee
style G fill:#fce4ec
Loading

📁 Package Structure

j2534-api/
├── J2534/ # Low-level PassThru API
│ ├── api.py # High-level API functions
│ ├── config.py # Debug/exception configuration
│ ├── constants.py # Protocol constants (IntEnum)
│ ├── dll_interface.py # DLL bindings
│ ├── exceptions.py # Exception hierarchy
│ ├── logging_utils.py # Debug utilities
│ └── structures.py # ctypes structures
│
├── AutoJ2534/ # High-level vehicle interface
│ ├── interface.py # J2534Communications class
│ ├── ecu_parameters.py # Connection configurations
│ └── negative_response_codes.py # UDS error codes
│
├── J2534_REGISTRY/ # Windows registry scanner
│ ├── registry_scanner.py # Device enumeration
│ └── device_info.py # Device dataclass
│
└── examples/ # GUI examples (4 frameworks)

🎨 GUI Examples

The library includes complete GUI examples using 4 different frameworks:

FrameworkDescriptionInstallation
TkinterBuilt-in Python GUINo installation needed
PyQt5Professional cross-platformpip install j2534-api[gui-pyqt5]
CustomTkinterModern themed Tkinterpip install j2534-api[gui-customtkinter]
FreeSimpleGUIRapid prototypingpip install j2534-api[gui-pysimplegui]
# Run an examplecd examples/tkinter_example
python main.py

🔧 Configuration

🐛 Debug Mode
fromJ2534importj2534_config# Enable verbose debug outputj2534_config.enable_debug()
# Disable debug outputj2534_config.disable_debug()
# Check current stateifj2534_config.is_debug_enabled:
print("Debug mode is ON")
⚠️ Exception Mode
fromJ2534importj2534_config# Enable exception mode (raises J2534Error on failures)j2534_config.enable_exceptions()
# Disable exception mode (returns False/None on failures)j2534_config.disable_exceptions()
🚗 Pre-Defined Connections

The library includes pre-configured connection settings for common vehicles:

fromAutoJ2534importConnections# Available Chrysler/FCA configurationsprint(Connections.CHRYSLER_ECU.keys())
# ['chrys1', 'chrys2', 'chrys3', 'chrys4', 'chrys5', 'chrys6', 'chrys7', 'chrys8']# SCI protocol configurationsprint(Connections.SCI.keys())
# ['SCI_A_ENGINE', 'SCI_A_TRANS', 'SCI_B_ENGINE', 'SCI_B_TRANS']

⚠️ Error Handling

✅ With Exceptions (Recommended)
fromJ2534importj2534_config, pt_openfromJ2534.exceptionsimportJ2534OpenErrorj2534_config.enable_exceptions()
try:
device_id=pt_open()
exceptJ2534OpenErroraserror:
print(f"Failed to open device: {error}")
print(f"Error code: {error.error_code}")
❌ Without Exceptions
fromJ2534importpt_opendevice_id=pt_open()
ifdevice_idisFalse:
print("Failed to open device")

📚 Documentation

ModuleDescriptionLink
J2534Low-level PassThru API📖 Documentation
AutoJ2534High-level interface📖 Documentation
J2534_REGISTRYDevice discovery📖 Documentation
SAE J2534-1Official standard🔗 SAE Website

🐛 Troubleshooting

❌ No Devices Found
  1. Verify J2534 device drivers are installed
  2. Check USB connection to device
  3. Run as Administrator (registry access may require elevation)
  4. Confirm device appears in Windows Device Manager

[!TIP] Use get_all_j2534_devices() to see what devices are detected in the registry.

⏱️ Connection Timeouts
  1. Ensure vehicle ignition is ON
  2. Verify correct protocol and baud rate for your vehicle
  3. Increase timeout values in pt_read_message()
  4. Check OBD-II cable connection
📡 Message Filter Errors
  1. For ISO15765, flow control filter is REQUIRED
  2. Verify CAN IDs match your vehicle's ECU addresses
  3. Check filter mask is correctly configured

[!IMPORTANT] Standard OBD-II uses 0x7E0 (request) and 0x7E8 (response). Your vehicle may use different IDs.

💻 DLL Load Failures
  1. Ensure you're using 32-bit Python (most J2534 DLLs are 32-bit)
  2. Check the DLL path in the registry is correct
  3. Verify all DLL dependencies are present

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

  • SAE International for the J2534 PassThru standard
  • The Python community for excellent tooling
  • Claude AI for generating this README

Warning

Disclaimer: This software is provided for educational and research purposes. Always ensure you have proper authorization before performing vehicle diagnostics. The authors are not responsible for any damage or issues caused by the use of this software.

About

Python Interface to J2534 Api

Resources

Stars

58 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages