Quantex GmbH
DE RU EN EL
Your region: Europe

PassThruLogicalDisconnect v5.0

Closing a logical communication channel

Last updated:

Description

The function terminates the logical connection to the vehicle on the specified pass-thru device.

On success, the function returns STATUS_NOERROR, and the logical communication channel transitions to the disconnected state.

long PassThruLogicalDisconnect(unsigned long ChannelID)

Disconnected channel state

After disconnection, the logical channel has the following state:

Parameters

ChannelID

Input parameter. The identifier of the logical communication channel obtained from the call to PassThruLogicalConnect().

Return error codes

Code Description
STATUS_NOERROR Function completed successfully
ERR_CONCURRENT_API_CALL A J2534 API function was called before the previous call completed
ERR_DEVICE_NOT_OPEN PassThruOpen() has not been successfully called
ERR_INVALID_CHANNEL_ID Invalid ChannelID value
ERR_DEVICE_NOT_CONNECTED Communication error with the pass-thru device. The device has been disconnected.
ERR_NOT_SUPPORTED The DLL does not support this function
ERR_FAILED Undefined error. Use PassThruGetLastError() to get a description.

Examples

C/C++ example

#include "j2534_dll.hpp"

unsigned long logicalChannelID = ...; // ID obtained from PassThruLogicalConnect

// Close the logical channel
long ret = PassThruLogicalDisconnect(logicalChannelID);

if (ret == STATUS_NOERROR) {
    printf("Logical channel closed\n");
} else {
    char error[256];
    PassThruGetLastError(error);
    printf("Error: %s\n", error);
}

Python example (ctypes)

from ctypes import *

j2534 = cdll.LoadLibrary("libj2534_v05_00.dylib")

logical_channel_id = c_ulong(...)  # ID obtained from PassThruLogicalConnect

# Close the logical channel
ret = j2534.PassThruLogicalDisconnect(logical_channel_id)

if ret == 0:  # STATUS_NOERROR
    print("Logical channel closed")
else:
    error = create_string_buffer(256)
    j2534.PassThruGetLastError(error)
    print(f"Error: {error.value.decode()}")

Related functions