### Quick Start Bash Script Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/README.md Follow these steps to set up and run a J2534 API GUI example. Choose a framework, install dependencies, and execute the main script. ```bash # 1. Choose a framework cd pyqt5_example # or tkinter_example, etc. # 2. Install dependencies (if any) pip install -r requirements.txt # 3. Run the example python main.py ``` -------------------------------- ### Run PyQt5 Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/examples/README.md Install PyQt5, navigate to the PyQt5 example directory, and run the main script. This example is suitable for professional applications. ```bash pip install PyQt5 cd J2534/examples/pyqt5_example python main.py ``` -------------------------------- ### Run FreeSimpleGUI Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/examples/README.md Install FreeSimpleGUI, navigate to the FreeSimpleGUI example directory, and run the main script. This example is best for rapid prototyping. ```bash pip install FreeSimpleGUI cd J2534/examples/pysimplegui_example python main.py ``` -------------------------------- ### Install and Run Tkinter Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/tkinter_example/README.md Navigate to the example directory and run the main Python script. No external dependencies need to be installed as Tkinter is built into Python. ```bash # No installation needed! Tkinter comes with Python cd examples/tkinter_example python main.py ``` -------------------------------- ### Run Other Framework Examples Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534_REGISTRY/examples/README.md Install the desired framework (CustomTkinter, PySimpleGUI, or PyQt5) using pip, then navigate to the respective example directory and run the main script. ```bash # Install the framework pip install customtkinter # or PySimpleGUI, PyQt5 # Run the example cd customtkinter_registry_viewer python main.py ``` -------------------------------- ### Run CustomTkinter Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/examples/README.md Install customtkinter, navigate to the CustomTkinter example directory, and run the main script. This example is ideal for modern themed UIs. ```bash pip install customtkinter cd J2534/examples/customtkinter_example python main.py ``` -------------------------------- ### Run Tkinter Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534_REGISTRY/examples/README.md Navigate to the tkinter_registry_viewer directory and run the main script to start the Tkinter-based GUI. ```bash cd tkinter_registry_viewer python main.py ``` -------------------------------- ### Install j2534-api with GUI Support Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Install the library with optional support for various GUI frameworks. Use `gui-all` to include all supported frameworks. ```bash pip install j2534-api[gui-pyqt5] ``` ```bash pip install j2534-api[gui-customtkinter] ``` ```bash pip install j2534-api[gui-all] ``` -------------------------------- ### One-Line Connection with quick_connect Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/README.md Use `quick_connect()` for instant setup to device 0 with the default profile. Ensure to check if the connection was successful before proceeding. ```python from AutoJ2534 import quick_connect comm = quick_connect() # Connect to device 0 with default profile if comm: print(f"VIN: {comm.read_vin()}") comm.close() ``` -------------------------------- ### Run Tkinter Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/examples/README.md Navigate to the Tkinter example directory and run the main script. This example has no external dependencies. ```bash cd J2534/examples/tkinter_example python main.py ``` -------------------------------- ### Run Tkinter GUI Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Navigate to the Tkinter example directory and run the main script to launch the GUI. ```bash cd examples/tkinter_example python main.py ``` -------------------------------- ### Install PyQt5 Dependencies Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/pyqt5_example/README.md Install the necessary PyQt5 library using pip. Ensure you have a requirements.txt file or install manually. ```bash pip install -r requirements.txt ``` ```bash pip install PyQt5 ``` -------------------------------- ### Manual Connection with Configuration Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Connect to a specific J2534 device by its index and use a predefined connection configuration. This example shows how to list devices, open communication, get device info, check battery voltage, and send diagnostic requests. ```python from AutoJ2534 import j2534_communication, Connections # List available devices j2534_communication.numbered_tool_list() # Connect to device 0 with Chrysler PCM configuration if j2534_communication.open_communication(device_index=0, connection_name="chrys1"): # Get device info info = j2534_communication.tool_info() print(f"Device: {info[0]}, FW: {info[1]}, DLL: {info[2]}") # Check battery voltage voltage = j2534_communication.check_volts() print(f"Battery: {voltage:.2f}V") # Send diagnostic request response = j2534_communication.transmit_and_receive_message([0x10, 0x01]) print(f"Response: {response}") # Disconnect j2534_communication.disconnect() j2534_communication.close() ``` -------------------------------- ### Run PyQt5 J2534 Diagnostic Tool Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/pyqt5_example/README.md Navigate to the example directory and run the main Python script to launch the diagnostic tool. ```bash cd examples/pyqt5_example python main.py ``` -------------------------------- ### Install j2534-api from Source Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Clone the repository and install the library in editable mode. This is useful for development or when using the latest unreleased code. ```bash git clone https://github.com/keenanlaws/j2534-api.git cd j2534-api pip install -e . ``` -------------------------------- ### Install and Run PySimpleGUI App Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/pysimplegui_example/README.md Installs project dependencies and runs the main Python script. Ensure requirements.txt is present. ```bash pip install -r requirements.txt python main.py ``` -------------------------------- ### Integrate with J2534 Devices Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534_REGISTRY/README.md Example of how to discover available J2534 devices, present them in a selection menu, and then connect to a selected device using the J2534 library. ```python from J2534_REGISTRY import get_all_j2534_devices, J2534DeviceInfo from J2534 import pt_open, set_j2534_device_to_connect # Get available devices devices = get_all_j2534_devices() if not devices: print("No J2534 devices found!") exit(1) # Display selection menu print("Available J2534 Devices:") for i, device in enumerate(devices): print(f" {i}: {device.name}") # Select device (example: first one) selected_device = devices[0] print(f"Using: {selected_device.name}") # Use with J2534 module set_j2534_device_to_connect(selected_device.device_id) device_id = pt_open() ``` -------------------------------- ### ISO 15765 (CAN Diagnostics) Communication Example Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Provides a comprehensive example of setting up and communicating over ISO 15765 protocol. It includes opening a device, connecting to a channel, configuring the required flow control filter, sending a VIN request, reading the response, and disconnecting. ```python from J2534 import ( pt_open, pt_close, pt_connect, pt_disconnect, pt_read_message, pt_write_message, pt_start_ecu_filter, set_j2534_device_to_connect, ProtocolId, BaudRate, TxFlags, PassThruMsgBuilder ) # Open device and connect ISO15765 channel set_j2534_device_to_connect(0) device_id = pt_open() channel_id = pt_connect(device_id, ProtocolId.ISO15765, 0, BaudRate.CAN_500K) # Flow control filter is REQUIRED for ISO15765 # Standard OBD-II: Request 0x7DF (broadcast) or 0x7E0, Response 0x7E8 pt_start_ecu_filter( channel_id, ProtocolId.ISO15765, mask_identifier=0xFFFFFFFF, pattern_identifier=0x7E8, # ECU response CAN ID flow_control_identifier=0x7E0 # Tester request CAN ID ) # Read VIN (UDS Service 0x22, DID 0xF190) tx_msg = PassThruMsgBuilder(ProtocolId.ISO15765, TxFlags.ISO15765_FRAME_PAD) tx_msg.set_identifier_and_data(0x7E0, [0x22, 0xF1, 0x90]) pt_write_message(channel_id, tx_msg, 1, 1000) # Read response rx_msg = PassThruMsgBuilder(ProtocolId.ISO15765, 0) if pt_read_message(channel_id, rx_msg, 1, 2000) == 0: print(f"VIN Response: {rx_msg.dump_output()}") pt_disconnect(channel_id) pt_close(device_id) ``` -------------------------------- ### Basic CustomTkinter Application Structure Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/customtkinter_example/README.md Sets up a basic CustomTkinter application with dark mode, a blue theme, a button, and an entry field. Ensure CustomTkinter is installed. ```python import customtkinter as ctk ctk.set_appearance_mode("dark") ctk.set_default_color_theme("blue") class App(ctk.CTk): def __init__(self): super().__init__() self.title("My App") ctk.CTkButton(self, text="Click", command=func).pack() ctk.CTkEntry(self, placeholder_text="Type here").pack() app = App() app.mainloop() ``` -------------------------------- ### Quick Start: J2534 Device Communication Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md This example demonstrates the basic workflow of listing devices, opening a connection, sending a CAN message, and reading a response using the J2534 module. A flow control filter is required for ISO 15765 (CAN diagnostics). ```python from J2534 import ( get_list_j2534_devices, set_j2534_device_to_connect, pt_open, pt_close, pt_connect, pt_disconnect, pt_read_message, pt_write_message, pt_start_ecu_filter, ProtocolId, BaudRate, TxFlags, PassThruMsgBuilder ) # 1. List available J2534 devices devices = get_list_j2534_devices() for index, (name, dll_path) in enumerate(devices): print(f"{index}: {name}") # 2. Select a device (by index) set_j2534_device_to_connect(0) # 3. Open the device device_id = pt_open() if device_id is False: print("Failed to open device") exit(1) # 4. Connect a channel (ISO 15765 / CAN) channel_id = pt_connect( device_id, ProtocolId.ISO15765, 0, # flags BaudRate.CAN_500K ) # 5. Set up a flow control filter (required for ISO 15765) filter_id = pt_start_ecu_filter( channel_id, ProtocolId.ISO15765, mask_identifier=0xFFFFFFFF, pattern_identifier=0x7E8, # ECU response ID flow_control_identifier=0x7E0 # Tester request ID ) # 6. Create and send a message tx_message = PassThruMsgBuilder(ProtocolId.ISO15765, TxFlags.ISO15765_FRAME_PAD) tx_message.set_identifier_and_data(0x7E0, [0x22, 0xF1, 0x90]) # Read VIN pt_write_message(channel_id, tx_message, 1, 1000) # 7. Read the response rx_message = PassThruMsgBuilder(ProtocolId.ISO15765, 0) result = pt_read_message(channel_id, rx_message, 1, 1000) if result == 0: print(f"Response: {rx_message.dump_output()}") # 8. Clean up pt_disconnect(channel_id) pt_close(device_id) ``` -------------------------------- ### PyQt5 J2534 Diagnostic Tool Class Structure Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/pyqt5_example/README.md Overview of the main window class and its key methods for UI setup, device management, and communication. ```python # Main window class class J2534DiagnosticTool(QMainWindow): def setup_ui(self): # Build UI components def refresh_devices(self): # Scan registry for devices def connect_device(self): # Establish J2534 connection def disconnect_device(self): # Clean disconnect def send_message(self): # Transmit hex message def update_voltage(self): # Monitor battery voltage ``` -------------------------------- ### Tkinter Event Handling Examples Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/tkinter_example/README.md Demonstrates how to bind events to Tkinter widgets, including button clicks, keyboard return key presses, and handling window close events using root.protocol. ```python # Button click button.config(command=my_function) # Keyboard event entry.bind("", lambda e: send_message()) # Window close root.protocol("WM_DELETE_WINDOW", on_closing) ``` -------------------------------- ### Connect ISO 14230 / KWP2000 at 10.4 kbps Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Connects using the ISO 14230 (KWP2000) protocol, common in European vehicles, at 10.4 kbps. This protocol supports fast initialization, automatically handled by the J2534 device. The snippet demonstrates sending a 'Start Diagnostic Session' request and interpreting the response. ```python from J2534 import ( pt_open, pt_close, pt_connect, pt_disconnect, pt_read_message, pt_write_message, pt_start_message_filter, pt_ioctl, set_j2534_device_to_connect, ProtocolId, BaudRate, IoctlId, PassThruMsgBuilder ) # Connect ISO 14230 at 10.4 kbps set_j2534_device_to_connect(0) device_id = pt_open() channel_id = pt_connect( device_id, ProtocolId.ISO14230, 0, BaudRate.ISO_10400 ) # ISO 14230 supports fast initialization (25ms wake-up pattern) # This is handled automatically by the J2534 device # Pass filter pt_start_message_filter( channel_id, 0, mask=[0x00], pattern=[0x00] ) # KWP2000 Start Diagnostic Session (Service 0x10) tx_msg = PassThruMsgBuilder(ProtocolId.ISO14230, 0) tx_msg.build_transmit_data_block([ 0xC0, # Format byte: Physical addressing, length in header 0x33, # Target: ECU address 0xF1, # Source: Tester address 0x10, 0x85 # StartDiagnosticSession, Extended session ]) pt_write_message(channel_id, tx_msg, 1, 1000) # Read response rx_msg = PassThruMsgBuilder(ProtocolId.ISO14230, 0) if pt_read_message(channel_id, rx_msg, 1, 3000) == 0: data = rx_msg.get_data_bytes() if data[3] == 0x50: # Positive response print("KWP2000 session started successfully") elif data[3] == 0x7F: # Negative response print(f"KWP2000 error: NRC 0x{data[5]:02X}") pt_disconnect(channel_id) pt_close(device_id) ``` -------------------------------- ### Using J2534RegistryScanner Class Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534_REGISTRY/README.md Instantiate the J2534RegistryScanner class to access advanced device scanning functionalities. This includes filtering by protocol, getting devices by index, and verifying DLL existence. ```python from J2534_REGISTRY import J2534RegistryScanner scanner = J2534RegistryScanner() # Get all devices all_devices = scanner.get_all_devices() # Get devices by protocol can_devices = scanner.get_devices_by_protocol("CAN") iso_devices = scanner.get_devices_by_protocol("ISO15765") # Get device by index device = scanner.get_device_by_index(0) # Get only devices with valid DLL files valid_devices = scanner.get_valid_devices() # Refresh cache scanner.refresh_cache() ``` -------------------------------- ### Low-Level API Access for J2534 Communication Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Utilize the low-level J2534 API for direct control over device operations. This example demonstrates enabling debug and exception modes, listing devices, opening a device, connecting with ISO15765 protocol, setting up an ECU filter, sending a message, and reading a response. ```python from J2534 import ( 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 logging j2534_config.enable_debug() # Enable exception mode (raises exceptions on errors) j2534_config.enable_exceptions() # List and select device devices = get_list_j2534_devices() print(f"Found {len(devices)} devices") set_j2534_device_to_connect(0) # Open device device_id = pt_open() # Connect with ISO15765 protocol channel_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 ID flow_control_identifier=0x7E0 # Tester request ID ) # Create and send a message tx_msg = PassThruMsgBuilder(ProtocolId.ISO15765, TxFlags.ISO15765_FRAME_PAD) tx_msg.set_identifier_and_data(0x7E0, [0x3E, 0x00]) # TesterPresent pt_write_message(channel_id, tx_msg, 1, 1000) # Read response rx_msg = PassThruMsgBuilder(ProtocolId.ISO15765, 0) if pt_read_message(channel_id, rx_msg, 1, 2000) == 0: print(f"Response: {rx_msg.dump_output()}") # Clean up pt_disconnect(channel_id) pt_close(device_id) ``` -------------------------------- ### Tkinter Grid Layout Options Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/tkinter_example/README.md Examples of using the grid geometry manager for widget placement, including sticky options for expansion and spanning multiple columns or rows. Padding can also be applied. ```python # Grid positioning widget.grid(row=0, column=0, sticky="ew") # East-West expansion widget.grid(row=1, column=0, columnspan=2) # Span 2 columns widget.grid(row=0, column=0, padx=5, pady=5) # Padding ``` -------------------------------- ### Device Discovery - get_all_j2534_devices Source: https://context7.com/keenanlaws/python-j2534-interface/llms.txt Scans the Windows registry to find all registered J2534 PassThru devices installed on the system. Returns device information including name, vendor, DLL path, and supported protocols. ```APIDOC ## Device Discovery - get_all_j2534_devices ### Description Scans the Windows registry to find all registered J2534 PassThru devices installed on the system. Returns device information including name, vendor, DLL path, and supported protocols. ### Method ```python from J2534_REGISTRY import get_all_j2534_devices, find_device_by_name # List all registered J2534 devices devices = get_all_j2534_devices() for device in devices: print(f"Device: {device.name}") print(f" Vendor: {device.vendor}") print(f" DLL: {device.function_library_path}") print(f" Protocols: {', '.join(device.supported_protocols)}") print() # Find a specific device by name (partial match) mongoose = find_device_by_name("Mongoose") if mongoose: print(f"Found Mongoose at: {mongoose.function_library_path}") print(f"Supports CAN: {mongoose.can_iso15765}") ``` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **devices** (list) - A list of dictionaries, where each dictionary contains information about a J2534 device. - **name** (str) - The name of the device. - **vendor** (str) - The vendor of the device. - **function_library_path** (str) - The path to the device's DLL. - **supported_protocols** (list of str) - A list of supported automotive protocols. #### Response Example ```json [ { "name": "Mongoose", "vendor": "Drew Technologies", "function_library_path": "C:\\Program Files\\Drew Technologies\\Mongoose\\mongoose.dll", "supported_protocols": ["CAN", "ISO15765", "J1850VPW", "ISO9141", "KWP2000"] } ] ``` ``` -------------------------------- ### Change Voltage Update Interval Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/pyqt5_example/README.md Modify the timer interval to change how frequently the battery voltage is updated. This example sets it to 3 seconds. ```python # Voltage update every 3 seconds instead of 5 self.voltage_timer.start(3000) ``` -------------------------------- ### Quick Connect - quick_connect Source: https://context7.com/keenanlaws/python-j2534-interface/llms.txt Creates a J2534Communications instance and opens communication with a specified device and connection profile in a single function call. Ideal for rapid development and testing. ```APIDOC ## Quick Connect - quick_connect ### Description Creates a J2534Communications instance and opens communication with a specified device and connection profile in a single function call. Ideal for rapid development and testing. ### Method ```python from AutoJ2534 import quick_connect # Quick one-line connection to first device using Chrysler 11-bit CAN profile comm = quick_connect(device_index=0, connection_name="chrys1") if comm: # Read the Vehicle Identification Number vin = comm.read_vin() print(f"VIN: {vin}") # Send tester present to keep session alive comm.tester_present() # Check battery voltage voltage = comm.check_volts() print(f"Battery Voltage: {voltage:.2f}V") # Clean up comm.disconnect() comm.close() ``` ### Parameters #### Query Parameters - **device_index** (int) - Required - The index of the J2534 device to connect to. - **connection_name** (str) - Required - The name of the connection profile to use. ### Request Example None ### Response #### Success Response (200) - **comm** (J2534Communications) - An instance of the J2534Communications class connected to the specified device and profile. #### Response Example ```python # comm object representing an active J2534 connection ``` ``` -------------------------------- ### Get All J2534 Devices Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534_REGISTRY/README.md Use this function to retrieve a list of all registered J2534 devices. It iterates through the registry and collects information for each device found. ```python from J2534_REGISTRY import get_all_j2534_devices devices = get_all_j2534_devices() for device in devices: print(f"{device.name}") print(f" DLL: {device.function_library_path}") print(f" Protocols: {', '.join(device.supported_protocols)}") ``` -------------------------------- ### Git Workflow for Contributions Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Follow these steps to contribute to the project: fork the repository, create a feature branch, commit changes, push to the branch, and open a Pull Request. ```bash git checkout -b feature/amazing-feature ``` ```bash git commit -m 'Add amazing feature' ``` ```bash git push origin feature/amazing-feature ``` -------------------------------- ### Using PassThruMsgBuilder Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Demonstrates the initialization of PassThruMsgBuilder, which is used for constructing J2534 messages. This snippet requires imports for PassThruMsgBuilder, ProtocolId, and TxFlags. ```python from J2534 import PassThruMsgBuilder, ProtocolId, TxFlags ``` -------------------------------- ### Advanced J2534 Device Scanning Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534_REGISTRY/examples/README.md Shows advanced usage of the J2534RegistryScanner class to filter devices by protocol, get only valid devices (with existing DLLs), and force a cache refresh. ```python # Advanced usage with scanner scanner = J2534RegistryScanner() can_devices = scanner.get_devices_by_protocol("CAN") valid_devices = scanner.get_valid_devices() # Only devices with existing DLLs scanner.refresh_cache() # Force rescan ``` -------------------------------- ### Open Device and Log Operations Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Opens a connection to a J2534 device and demonstrates logging of the open operation's calls and return values. Ensure to disable debugging when done. ```python device_id = pt_open() # Logs: "pt_open: Called" # Logs: "pt_open: Returned 1 (success)" # Disable when done j2534_config.disable_debug() ``` -------------------------------- ### ISO 9141 (K-Line) Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Initializes and prepares for communication using the ISO 9141 (K-Line) protocol, which requires a 5-baud initialization sequence. This snippet includes necessary imports for K-Line communication. ```python from J2534 import ( pt_open, pt_close, pt_connect, pt_disconnect, pt_read_message, pt_write_message, pt_start_message_filter, pt_ioctl, set_j2534_device_to_connect, ProtocolId, BaudRate, IoctlId, PassThruMsgBuilder ) ``` -------------------------------- ### Handle J2534 Open Errors with Exceptions Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Demonstrates how to open a J2534 device and catch potential `J2534OpenError` exceptions when exception mode is enabled. Includes printing the error message and error code. ```python from J2534 import j2534_config, pt_open from J2534.exceptions import J2534OpenError j2534_config.enable_exceptions() try: device_id = pt_open() except J2534OpenError as error: print(f"Failed to open device: {error}") print(f"Error code: {error.error_code}") ``` -------------------------------- ### Enable Debug Mode for Migration Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/CHANGELOG.md Shows how to enable debug mode using `j2534_config.enable_debug()` to help verify behavior during migration from older versions to 2.0. This is a recommended step for a smoother transition. ```python from J2534 import j2534_config j2534_config.enable_debug() ``` -------------------------------- ### Discover J2534 Devices Source: https://context7.com/keenanlaws/python-j2534-interface/llms.txt Scans the Windows registry to find all installed J2534 PassThru devices. Lists device name, vendor, DLL path, and supported protocols. Can also find specific devices by name. ```python from J2534_REGISTRY import get_all_j2534_devices, find_device_by_name # List all registered J2534 devices devices = get_all_j2534_devices() for device in devices: print(f"Device: {device.name}") print(f" Vendor: {device.vendor}") print(f" DLL: {device.function_library_path}") print(f" Protocols: {', '.join(device.supported_protocols)}") print() # Find a specific device by name (partial match) mongoose = find_device_by_name("Mongoose") if mongoose: print(f"Found Mongoose at: {mongoose.function_library_path}") print(f"Supports CAN: {mongoose.can_iso15765}") ``` -------------------------------- ### Requirements Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/README.md Lists the software and hardware requirements for using the library. ```APIDOC ## Requirements - **Python Version**: 3.10 or higher - **Operating System**: Windows (due to reliance on `winreg`) - **Hardware**: A compatible J2534 device with its drivers installed. ``` -------------------------------- ### Connect SCI Protocol (Chrysler/Stellantis) - SCI-B Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Connects to Chrysler/Stellantis vehicles using the SCI-B protocol (high speed, 62,500 baud) for high-speed data transfer, such as flash programming. This section outlines the connection setup for SCI-B. ```python # SCI-B (high speed) - 62,500 baud channel_id = pt_connect( device_id, ProtocolId.SCI_B_ENGINE, # Or SCI_B_TRANS 0, BaudRate.SCI_62500 ) # SCI-B is used for high-speed data transfer (flash programming) # ... operations ... pt_disconnect(channel_id) pt_close(device_id) ``` -------------------------------- ### Add Predefined Messages for Quick Sending Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/pyqt5_example/README.md Implement quick-send buttons for predefined messages, such as 'Tester Present' or 'Read VIN', by connecting button clicks to a send function. ```python # Add quick-send buttons quick_buttons = QHBoxLayout() for name, data in [("Tester Present", "3E 00"), ("Read VIN", "22 F1 90")]: btn = QPushButton(name) btn.clicked.connect(lambda _, d=data: self.quick_send(d)) quick_buttons.addWidget(btn) ``` -------------------------------- ### Basic J2534 Device Retrieval and Printing Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534_REGISTRY/examples/README.md Demonstrates basic usage of the J2534_REGISTRY module to retrieve all registered devices and print their names, vendors, DLL paths, and supported protocols. ```python from J2534_REGISTRY import ( get_all_j2534_devices, find_device_by_name, get_device_count, J2534RegistryScanner, J2534DeviceInfo, REGISTRY_PATH_64BIT, REGISTRY_PATH_32BIT, ) # Basic usage devices = get_all_j2534_devices() for device in devices: print(f"{device.name} - {device.vendor}") print(f" DLL: {device.function_library_path}") print(f" Protocols: {', '.join(device.supported_protocols)}") ``` -------------------------------- ### Create and Build a PassThru Message Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Demonstrates how to construct a PassThru message using PassThruMsgBuilder, set its identifier and data, or build the transmit data block directly. Includes methods for debugging and outputting the message data. ```python from J2534 import PassThruMsgBuilder, ProtocolId, TxFlags # Create a message message = PassThruMsgBuilder( protocol_id=ProtocolId.ISO15765, transmit_flags=TxFlags.ISO15765_FRAME_PAD ) # Set CAN ID and data message.set_identifier_and_data(0x7E0, [0x22, 0xF1, 0x90]) # Or set just data (ID already in data for some protocols) message.build_transmit_data_block([0x00, 0x00, 0x07, 0xE0, 0x22, 0xF1, 0x90]) # Dump for debugging message.dump() # Prints all fields and hex dump print(message.dump_output()) # Just hex string: "000007E022F190" ``` -------------------------------- ### Raw CAN Communication and Filtering Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Illustrates how to establish a raw CAN connection for bus sniffing or custom protocols. It shows how to set up both a PASS filter to receive all messages and a PASS filter to receive a specific range of CAN IDs. ```python from J2534 import ( pt_open, pt_close, pt_connect, pt_disconnect, pt_read_message, pt_write_message, pt_start_message_filter, set_j2534_device_to_connect, ProtocolId, BaudRate, FilterType, PassThruMsgBuilder, clear_receive_buffer ) # Connect raw CAN channel set_j2534_device_to_connect(0) device_id = pt_open() channel_id = pt_connect(device_id, ProtocolId.CAN, 0, BaudRate.CAN_500K) # Pass filter - receive ALL CAN messages (bus sniffing) pt_start_message_filter( channel_id, FilterType.PASS_FILTER, mask=[0x00, 0x00, 0x00, 0x00], # Match any ID pattern=[0x00, 0x00, 0x00, 0x00] ) # Or block filter - receive specific range (e.g., 0x700-0x7FF) pt_start_message_filter( channel_id, FilterType.PASS_FILTER, mask=[0x00, 0x00, 0x07, 0x00], # Mask: check bits 8-10 pattern=[0x00, 0x00, 0x07, 0x00] # Pattern: 0x7xx ) ``` -------------------------------- ### Access Pre-Defined Connections Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md View available pre-configured connection settings for Chrysler/FCA vehicles and SCI protocols. Use `.keys()` to list available configurations. ```python from AutoJ2534 import Connections # Available Chrysler/FCA configurations print(Connections.CHRYSLER_ECU.keys()) # ['chrys1', 'chrys2', 'chrys3', 'chrys4', 'chrys5', 'chrys6', 'chrys7', 'chrys8'] # SCI protocol configurations print(Connections.SCI.keys()) # ['SCI_A_ENGINE', 'SCI_A_TRANS', 'SCI_B_ENGINE', 'SCI_B_TRANS'] ``` -------------------------------- ### Configure Custom Logging for J2534 Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/J2534/README.md Sets up a file handler for custom logging and enables debug mode for the J2534 interface. Ensure the 'j2534_debug.log' file is accessible. ```python import logging from J2534.config import j2534_config # Add file handler file_handler = logging.FileHandler('j2534_debug.log') file_handler.setFormatter(logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s' )) j2534_config.logger.addHandler(file_handler) # Enable debug j2534_config.enable_debug() ``` -------------------------------- ### PySimpleGUI Basic Window and Event Loop Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/pysimplegui_example/README.md Defines a simple GUI layout with a text input and buttons, creates a window, and processes events including window closure and button clicks. Input values are printed to the console. ```python # Define layout as nested lists layout = [ [sg.Text("Label"), sg.Input(key="-INPUT-")], [sg.Button("OK"), sg.Button("Cancel")] ] # Create window window = sg.Window("Title", layout) # Event loop while True: event, values = window.read() if event == sg.WIN_CLOSED: break if event == "OK": print(values["-INPUT-"]) window.close() ``` -------------------------------- ### List Available J2534 Devices in Python Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/README.md Use the `get_all_j2534_devices` function to discover and list all connected J2534 devices. It provides details like device name, vendor, DLL path, and supported protocols. ```python from J2534_REGISTRY import get_all_j2534_devices devices = get_all_j2534_devices() for device in devices: print(f"{device.name} - {device.vendor}") print(f" DLL: {device.function_library_path}") print(f" Protocols: {', '.join(device.supported_protocols)}") ``` -------------------------------- ### Load and Inspect Connection Profiles Source: https://context7.com/keenanlaws/python-j2534-interface/llms.txt Loads pre-defined connection configurations for various vehicle ECUs. Use `Connections.list_available_configs()` to see all options and access specific profiles like `Connections.CHRYSLER_ECU['chrys1']`. ```python from AutoJ2534 import Connections, ConnectionConfig, create_custom_can_config ``` ```python # List available Chrysler configurations print("Available profiles:") for key in Connections.list_available_configs(): config = Connections.CHRYSLER_ECU[key] print(f" {key}: {config.name} ({config.protocol_name})") ``` ```python # Get specific configuration details chrys1 = Connections.CHRYSLER_ECU['chrys1'] print(f" {chrys1.name}:") print(f" Protocol: {chrys1.protocol_name} (ID: {chrys1.protocol_id})") print(f" Baud Rate: {chrys1.baud_rate}") print(f" TX ID: 0x{chrys1.transmit_id:X}") print(f" RX ID: 0x{chrys1.receive_id:X}") print(f" TX Flags: 0x{chrys1.transmit_flags:X}") ``` ```python # Get only CAN-based configurations can_configs = Connections.get_chrysler_can_configs() print(f" CAN configurations: {list(can_configs.keys())}") ``` ```python # Get SCI protocol configurations sci_configs = Connections.get_chrysler_sci_configs() print(f"SCI configurations: {list(sci_configs.keys())}") ``` ```python # Create custom CAN configuration my_config = create_custom_can_config( name="My Custom ECU", transmit_id=0x7E0, receive_id=0x7E8, baud_rate=500000, use_29bit_addressing=False, communication_check=[0x3E, 0x00] # Tester Present ) print(f" Custom config: {my_config.name}") ``` -------------------------------- ### Tkinter Timer and Scheduling Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/AutoJ2534/examples/tkinter_example/README.md Shows how to schedule a function to be called after a delay using root.after and how to cancel a scheduled timer using root.after_cancel. ```python # One-shot timer timer_id = root.after(5000, callback_function) # Cancel timer root.after_cancel(timer_id) ``` -------------------------------- ### Use Compatibility Aliases (Deprecated) Source: https://github.com/keenanlaws/python-j2534-interface/blob/master/CHANGELOG.md Demonstrates the use of deprecated compatibility aliases for imports that still work but are marked for removal. It is recommended to update to the new import paths. ```python # These still work but are deprecated from AutoJ2534 import Interface, EcuParameters ``` -------------------------------- ### Build and Send J2534 Messages Source: https://context7.com/keenanlaws/python-j2534-interface/llms.txt Demonstrates how to construct different types of J2534 messages, including ISO15765, raw CAN, and SCI protocols, and prepare them for transmission. ```python tx_msg.set_identifier_and_data(0x7E0, [0x22, 0xF1, 0x90]) ``` ```python rx_msg = PassThruMsgBuilder(ProtocolId.ISO15765, 0) ``` ```python can_msg = PassThruMsgBuilder(ProtocolId.CAN, 0) ``` ```python can_msg.set_identifier_and_data(0x7DF, [0x01, 0x00]) ``` ```python sci_msg = PassThruMsgBuilder(ProtocolId.SCI_A_ENGINE, 0) ``` ```python sci_msg.build_transmit_data_block([0x2A, 0x0F]) ```