Close an ISO-TP session previously created by the canitpSessionCreate function
Input:
handle : SYSHANDLE
The handle to the ISO-TP session to close.
Returns: INT
1
|
- Successful.
|
0
|
- Not available.
|
-1
|
- ISO-TP session is not open.
|
-2
|
- Invalid handle.
|
Declaration:
FUNCTION canitpSessionDestroy : INT;
VAR_INPUT
handle : ACCESS SYSHANDLE;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR
buf : ARRAY [1..4096] OF SINT;
END_VAR;
FUNCTION CALLBACK canitpRecv
VAR_INPUT
handle : SYSHANDLE;
arg : DINT;
size : INT;
END_VAR;
DebugMsg(message := strFromMemory(src := PTR(arg), len := size));
END_FUNCTION;
PROGRAM example;
VAR
handle: SYSHANDLE;
rc : INT;
str : STRING;
out : ARRAY [1..4095] OF SINT;
len : INT;
END_VAR;
canOpen(baud := 250, monitor := FALSE);
rc := canitpSessionCreate(handle:=handle,
port := 1,
src := 16#12345678,
dst := 16#12345679,
cb_receive := @canitpRecv,
cb_data := ADDR(buf),
cb_arg := DINT(ADDR(buf)),
cb_size := SIZEOF(buf));
IF rc < 1 THEN
DebugFmt(message := "canitpSessionCreate=\1", v1 := rc);
RETURN;
END_IF;
rc := canitpSessionDestroy(handle:=handle);
IF rc < 1 THEN
DebugFmt(message := "canitpSessionDestroy=\1", v1 := rc);
RETURN;
END_IF;
BEGIN
END;
END_PROGRAM;
|