Quantex GmbH
Your region: Europe

PassThruDisconnect v4.04 v5.0

Closing a connection

Last updated:

Description

The function terminates the connection over the protocol that was previously established by the PassThruConnect command. All periodic messages and filters associated with this channel are removed automatically.

long PassThruDisconnect(unsigned long ChannelID)
Important: When the channel is closed, all active periodic messages (PassThruStartPeriodicMsg) and filters (PassThruStartMsgFilter) for this channel are automatically stopped and removed.

Parameters

Return error codes

Code Description Possible causes and solutions
STATUS_NOERROR Function completed successfully
ERR_INVALID_CHANNEL_ID A non-existent ChannelID was specified
  • ChannelID was not obtained from PassThruConnect
  • Solution: Make sure you are using the ChannelID returned by the PassThruConnect function
  • The channel has already been closed
  • Solution: Check that PassThruDisconnect has not been called again for this channel
ERR_DEVICE_NOT_CONNECTED No connection to the adapter
  • The connection to the adapter was lost
  • Solution: Check the network connection or the BLE connection
  • The device was closed via PassThruClose
  • Solution: Call PassThruOpen to reconnect

Examples

C/C++ example

#include "j2534_dll.hpp"

// ChannelID obtained earlier from PassThruConnect
unsigned long ChannelID;
long ret = PassThruDisconnect(ChannelID);
if (ret != STATUS_NOERROR) {
    char error[256];
    PassThruGetLastError(error);
    // Error handling
}

Kotlin example (Android)

// channelID obtained earlier from ptConnect
val result = j2534.ptDisconnect(channelID)
if (result.status == STATUS_NOERROR) {
    Log.i("J2534", "Communication channel closed")
} else {
    Log.e("J2534", "Channel close error: ${result.status}")
}

Python example

# channel_id obtained earlier from PassThruConnect
ret = j2534.PassThruDisconnect(channel_id)
if ret == 0:  # STATUS_NOERROR
    print("Communication channel closed")
else:
    print(f"Channel close error: {ret}")

C# example

// channelId obtained earlier from PassThruConnect
int ret = J2534.PassThruDisconnect(channelId);
if (ret == 0) {
    Console.WriteLine("Communication channel closed");
} else {
    Console.WriteLine($"Channel close error: {ret}");
}