Terminating communication with the adapter
Last updated:
The function terminates communication with the adapter and releases all associated resources. When it is called, all open channels (protocols) are closed automatically, so there is no need to call PassThruDisconnect() for each channel separately.
long PassThruClose(unsigned long DeviceID)
PassThruClose() before the program exits. If you do not, the next call to PassThruOpen() will return the error ERR_DEVICE_IN_USE.
PassThruOpen() function.| Code | Description | Possible causes and solutions |
|---|---|---|
| STATUS_NOERROR | Function completed successfully | - |
| ERR_INVALID_DEVICE_ID | Invalid device identifier |
|
| ERR_DEVICE_NOT_CONNECTED | Connection to the adapter has been lost |
|
| ERR_FAILED | Internal error |
|
#include "j2534_dll.hpp"
unsigned long DeviceID; // ID obtained from PassThruOpen
// ... working with the device ...
// Close the connection
long ret = PassThruClose(DeviceID);
if (ret != STATUS_NOERROR)
{
char error[256];
PassThruGetLastError(error);
printf("Close error: %s\n", error);
}
// deviceID obtained earlier from ptOpen
val result = j2534.ptClose(deviceID)
if (result.status == STATUS_NOERROR) {
Log.i("J2534", "Connection to the adapter closed")
} else {
Log.e("J2534", "Close error: ${result.status}")
}
from ctypes import *
# device_id obtained earlier from PassThruOpen
ret = j2534.PassThruClose(device_id)
if ret == 0: # STATUS_NOERROR
print("Connection closed")
else:
error = create_string_buffer(256)
j2534.PassThruGetLastError(error)
print(f"Error: {error.value.decode()}")
// deviceId obtained earlier from PassThruOpen
int ret = J2534.PassThruClose(deviceId);
if (ret == 0) // STATUS_NOERROR
{
Console.WriteLine("Connection closed");
}
else
{
var error = new System.Text.StringBuilder(256);
J2534.PassThruGetLastError(error);
Console.WriteLine($"Error: {error}");
}