canitpSessionCreate (Function) |
Top Previous Next |
Create an ISO-TP session using an already opened CAN port.
A callback function is used to notify the application that a message is received. (See CALLBACK for more information)
The ISO-TP protocol uses two way communication so the CAN write capability must be enabled. If CAN write is not enabled, or monitor mode is used, then messages cannot be received or send.
A maximum of 30 sessions can be created on a CAN port, if none of its filters are in use by the other functions. To create more than a total of 16 connections, it is necessary to reduce the size of the internal transmit and receive buffers. If e.g. only sending small messages, the transmit buffer can be reduced significantly, increasing the total number of connections.
Input: port : SINT (1/2) (default 1) The port of the CAN bus to use for ISO-TP.
src : DINT The CAN ID to filter for incoming ISO-TP messages.
dst : DINT The CAN ID where ISO-TP messages are sent to.
xtd : BOOL (default TRUE) Set to FALSE to use standard identifiers (11 bits), leave at TRUE for extended identifiers (29 bits).
cb_receive : CALLBACK The callback function for received messages. (See the canitpRecv callback declaration below)
cb_data : PTR The buffer where the received message will be stored.
cb_arg : DINT User argument to pass on to the callback. Can e.g. be used to select the buffer to read from.
cb_size : INT (1..4095) The size of the buffer to place the received data in. If an incoming ISO-TP message is too large for the receive buffer it will be discarded.
rx_size : INT (6..4095, default 4095) The size of the internal receive buffer. Can be reduced to increase the number of simultaneous sessions.
tx_size : INT (6..4095, default 4095) The size of the internal transmit buffer. Can be reduced to increase the number of simultaneous sessions.
Output: handle : SYSHANDLE The handle to this ISO-TP session.
Returns: INT
Declaration: FUNCTION canitpSessionCreate : INT;
Callback declaration: FUNCTION CALLBACK canitpRecv
Example: INCLUDE rtcu.inc |