canitpSend (Function) |
Top Previous Next |
Send an ISO-TP message. The destination of the message is set in the canitpOpen function, using the dst parameter.
Input: data : PTR The buffer with the message to send.
size : INT (1..4095) The size of the message in bytes.
Returns: INT
Declaration: FUNCTION canitpSend : INT;
Example: INCLUDE rtcu.inc
VAR buf : ARRAY [1..4096] OF SINT; END_VAR;
FUNCTION CALLBACK canitpRecv VAR_INPUT size : INT; END_VAR; DebugMsg(message := strFromMemory(src := ADDR(buf), len := size)); END_FUNCTION;
PROGRAM example; VAR rc : INT; str : STRING; out : ARRAY [1..4095] OF SINT; len : INT; END_VAR;
// Open can canOpen(baud := 250, monitor := FALSE);
// Open ISO-TP rc := canitpOpen(port := 1, src := 16#12345678, dst := 16#12345679, received := @canitpRecv, cb_data := ADDR(buf), cb_size := SIZEOF(buf)); IF rc < 1 THEN DebugFmt(message := "canitpOpen=\1", v1 := rc); RETURN; END_IF;
// Build message str := "Hello from RTCU device";
// Send message len := strLen(str := str); strToMemory(str := str, dst := ADDR(out), len := len); rc := canitpSend(data := ADDR(out), size := len); IF rc < 1 THEN DebugFmt(message := "canitpSend=\1", v1 := rc); RETURN; END_IF;
BEGIN END; END_PROGRAM; |