PyJ2534.dll¶
This module provides a Python-native implementation of the J2534-1 API.
Functions
Enumerate all registered J2534 04.04 Pass-Thru interface DLLs |
|
|
Load a J2534 DLL. |
Classes
|
Wrapper around a J2534-1 DLL. |
-
PyJ2534.dll.get_interfaces()¶ Enumerate all registered J2534 04.04 Pass-Thru interface DLLs
- Returns
A dict mapping display names of any registered J2534 Pass-Thru DLLs to their absolute filepath.
The name can be used in user-facing GUI elements to allow selection of a particular Pass-Thru device, and filepath can be passed to
load_interface()to instantiate aJ2534Dllwrapping the desired DLL.- Return type
dict
-
PyJ2534.dll.load_interface(dll_path)¶ Load a J2534 DLL.
- Parameters
dll_path (str) – Absolute filepath to the DLL to load
- Returns
A wrapper around the supplied DLL
- Return type
-
class
PyJ2534.dll.J2534Dll(dll_path)¶ Wrapper around a J2534-1 DLL.
Refer to the J2534-1 API specification for more information.
All functions raise a
J2534Errorif an error occurs.-
__init__(dll_path)¶ Instantiate a wrapper to the DLL at the given filepath.
-
PassThruOpen()¶ Open the Pass-Thru device.
- Returns
Handle to the opened device
- Return type
int
-
PassThruClose(device_id)¶ Close the Pass-Thru device
- Parameters
device_id (int) – Handle to the previously opened device
-
PassThruConnect(device_id, protocol, flags, baud)¶ Establish a Pass-Thru connection using the given device.
- Parameters
device_id (int) – Handle to the previously opened device
protocol (
ProtocolID) – Desired protocolflags (
ProtocolFlags) – Connection flagsbaud (int) – Desired baud rate
- Returns
Handle to the opened channel
- Return type
int
-
PassThruDisconnect(channel_id)¶ Close the specified Pass-Thru channel.
- Parameters
channel_id (int) – Handle to the previously opened channel
-
PassThruReadMsgs(channel_id, num_msgs=1, timeout=None)¶ Read messages from the specified channel.
- Parameters
channel_id (int) – Handle to the previously opened channel
num_msgs (int) – Number of messages to attempt to read.
timeout (int) –
Read timeout in ms, or None.
If None, then this function will return up to
num_msgsfrom the receive buffer (or nothing) and return immediately.Otherwise, this function will return either when the timeout has expired, an error occurs, or the specified number of messages has been read.
- Returns
list of
PyJ2534.define.PASSTHRU_MSGinstances.If no timeout is specified, up to
num_msgsmessages from the receive buffer are returned immediately.Otherwise, this function will return when
num_msgsmessages have been read from the receive buffer, or raises a timeoutJ2534Errorif the timeout lapses beforenum_msgsmessages have been read.- Return type
list
-
PassThruWriteMsgs(channel_id, msgs, timeout=None)¶ Write messages to the specified channel.
Returns the number of messages successfully transmitted (non-zero timeout) or queued (no timeout).
- Parameters
channel_id (int) – Handle to the previously opened channel
msgs (list) – list of
PASSTHRU_MSGinstancestimeout (int) – Write timeout in ms, or None
- Returns
Number of successfully transmitted/queued messages.
If no timeout is specified, the number of messages queued into the write buffer is returned immediately.
Otherwise, the number of transmitted messages is returned, or a timeout
J2534Erroris raised if the timeout lapses before all provided messages have been transmitted.- Return type
int
-
PassThruStartPeriodicMsg(channel_id, msg, interval)¶ Queue the specified message for periodic transmission.
- Parameters
channel_id (int) – Handle to the previously opened channel
msg (
PASSTHRU_MSG) – Message to be queuedinterval (int) – Period of transmissions, in ms. Valid intervals are between 5-65535ms
- Returns
Handle to the periodic message
- Return type
int
-
PassThruStopPeriodicMsg(channel_id, msg_id)¶ Stop the transmission of the specified message
- Parameters
channel_id (int) – Handle to the previously opened channel
msg_id (int) – Handle to the periodic message to stop
-
PassThruStartMsgFilter(channel_id, filter_type, mask_msg=None, pattern_msg=None, flow_msg=None)¶ Configure filtering for messages on the specified channel.
Keywords are to be specified as required. See the SAE J2534-1 recommended practices document for more information.
- Parameters
channel_id (int) – Handle to the previously opened channel
filter_type (
FilterType) – Type of filtermask_msg (
PASSTHRU_MSG) – Mask messagepattern_msg (
PASSTHRU_MSG) – Pattern messageflow_msg (
PASSTHRU_MSG) – ignored whenfilter_typeisPASS_FILTERorBLOCK_FILTER
- Returns
Handle to the created filter.
- Return type
int
-
PassThruStopMsgFilter(channel_id, filter_id)¶ Remove the specified filter from the specified channel.
- Parameters
channel_id (int) – Handle to the previously opened channel
filter_id (int) – Handle to the periodic message to stop
-
PassThruSetProgrammingVoltage(device_id, pin_number, voltage)¶ Set the programming voltage on the specified pin on the specified device.
- Parameters
device_id (int) – Handle to the previously opened device
pin_number (
ProgrammingPin) – Pin to setvoltage (int) – Voltage to apply to the pin. The voltage can either directly specified in mV, or via the
ProgrammingVoltageenumeration for cases where it’s desired to switch off the voltage or short the pin to GND. Acceptable ranges are between 5000 and 20000.
-
PassThruReadVersion(device_id)¶ Get version information.
- Parameters
device_id (int) – Handle to the previously opened device
- Returns
3-tuple of versions: (device firmware, DLL, and API)
- Return type
tuple
-
PassThruGetLastError()¶ Get the last error message generated by the interface.
- Returns
Error message
- Return type
str
-
PassThruIoctlGetConfig(channel_id, params)¶ Get protocol configuration parameters for the given channel.
- Parameters
channel_id (int) – Handle to the previously opened channel
params (list) – list of
IoctlParameterto retrieve values of
- Returns
dict mapping the requested
IoctlParameterto their currently set int values- Return type
dict
-
PassThruIoctlSetConfig(channel_id, params)¶ Set protocol configuration parameters for the given channel.
- Parameters
channel_id (int) – Handle to the previously opened channel
params (dict) – Mapping of
IoctlParameterto desired values
-
PassThruIoctlReadVbatt(device_id)¶ Read the voltage at pin 16 of the J1962 connector.
- Parameters
device_id (int) – Handle to the previously opened device
- Returns
Pin 16 voltage, in mV
- Return type
int
-
PassThruIoctlReadProgVoltage(device_id)¶ Read the programming voltage of the Pass-Thru device.
Returns an int indicating the voltage in mV
- Parameters
device_id (int) – Handle to the previously opened device
- Returns
Programming voltage, in mV
- Return type
int
-
PassThruIoctlFiveBaudInit(channel_id, addr)¶ Initiate a five-baud initialization.
- Parameters
channel_id (int) – Handle to the previously opened channel
addr (int) – Target address for initialization
- Returns
The response from the ECU
- Return type
bytes
-
PassThruIoctlFastInit(channel_id, msg=None)¶ Initiate a fast initialization.
- Parameters
channel_id (int) – Handle to the previously opened channel
msg (
PASSTHRU_MSG) – Message to be sent to the ECU for initialization.
- Returns
If a response is expected, a
PASSTHRU_MSGcontaining the response from the ECU,Noneotherwise.- Return type
-
PassThruIoctlClearTxBuffer(channel_id)¶ Clear the transmit messages queue.
- Parameters
channel_id (int) – Handle to the previously opened channel
-
PassThruIoctlClearRxBuffer(channel_id)¶ Clear the received messages queue.
- Parameters
channel_id (int) – Handle to the previously opened channel
-
PassThruIoctlClearPeriodicMsgs(channel_id)¶ Clear all configured periodic messages.
- Parameters
channel_id (int) – Handle to the previously opened channel
-
PassThruIoctlClearMsgFilters(channel_id)¶ Clear all configured filters.
- Parameters
channel_id (int) – Handle to the previously opened channel
-
PassThruIoctlClearFunctMsgLookupTable(channel_id)¶ Clear the functional message look-up table.
- Parameters
channel_id (int) – Handle to the previously opened channel
-
PassThruIoctlAddToFunctMsgLookupTable(channel_id, addrs)¶ Add addresses to the functional message look-up table.
- Parameters
channel_id (int) – Handle to the previously opened channel
addrs (list) – list of int containing the addresses to be added
-
PassThruIoctlDeleteFromFunctMsgLookupTable(channel_id, addrs)¶ Delete addresses to the functional message look-up table
- Parameters
channel_id (int) – Handle to the previously opened channel
addrs (list) – list of int containing the addresses to be deleted
-