Closing a connection
Last updated:
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)
PassThruStartPeriodicMsg) and filters (PassThruStartMsgFilter) for this channel are automatically
stopped and removed.
PassThruConnect command.| Code | Description | Possible causes and solutions |
|---|---|---|
| STATUS_NOERROR | Function completed successfully | — |
| ERR_INVALID_CHANNEL_ID | A non-existent ChannelID was specified |
|
| ERR_DEVICE_NOT_CONNECTED | No connection to the adapter |
|
#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
}
// 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}")
}
# 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}")
// 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}");
}