16

CAN-TP Protocol

 1 year ago
source link: https://piembsystech.com/can-tp-protocol/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CAN-TP Protocol

The ISO 15765-2 CAN-TP Protocol is an international standard protocol used for sending more than 8-bytes of data over the CAN consecutive frames. It was not possible in normal CAN data frames limited to the only maximum of 8 – bytes of the data. The ISO transport protocol is on the fourth layer
(transport layer) of the OSI layer model. The ISO TP defined a transmission method that allows to the send up to 4095 bytes via the CAN-bus. For this, the messages to be sent are segmented and individual CAN frames divided. The most common application for ISO-TP is the transfer of diagnostic messages with OBD-II equipped vehicles using KWP-2000 and UDS but is also used broadly in other application-specific CAN implementations. The CAN-TP is implemented over the CAN stack so to identify it there are two types of addressing which are:

  1. Basic Addressing.
  2. Extended Addressing.

BASIC ADDRESSING: CAN-TP Protocol basic addressing mode is called a normal addressing mode were to identify the CAN message or CAN-TP, we are using the CAN Identifier. So for this, there will be some identifier will be for CAN-TP, where if any message will receive then the server will understand that this TP message. The advantages of this type of addressing are that full 8 bytes of the data packet can be sent as data.

EXTENDED ADDRESSING: This addressing mode is the CAN-TP addressing mode where the 1st byte of the CAN data field will be used for the additional elements of the address whereby it reducing the data payload by one byte. The primary task of the transport protocol is to transfer messages which cannot be transmitted as a single Protocol Data Unit (PDU) due to their length. Messages which contain more data that can be transmitted within a single PDU are segmented by means of the transport protocol and divided into multiple, separate PDUs. This procedure can also be implemented on the data link layer. The segmentation of the message must then be carried out in PDUs of the corresponding data link protocol. So to send the data like CAN, the CAN-TP Protocol has been designed. Let us discuss how it can send multiple frames. So to make it possible, the CAN-TP also having 4-types frames like CAN protocol is:

  1. Single Frame.
  2. First Frame.
  3. Consecutive Frame.
  4. Flow Control Frame.
  1. SINGLE FRAME (SF): If the data payload is 7-bytes or less than that, then the single frame will be used for the data transfer in CAN-TP Protocol. Where the first byte of the data field is used for addressing. Again this byte is divided into two divisions, where the MSB 4-bit is used for addressing of TP frame type called PCI (protocol information). The LSB 4-bit is used for the DLC (Data Length Code).
CAN-TP: Single Frame Format

Basically, if you are going to spend less than then you can use the Single Frame else to send the more than that you have to use the other 3 frames. 

FIRST FRAME (FF): The first frame is an initial message of the multi-frame message packet in CAN-TP Protocol. It is used when more than 6 or 7 bytes of data segmented must be communicated. The first frame contains the length of the full packet, along with the initial data.  In FF, the first 2-bytes are used for the PCI, where the MSB 4-bit of the 1st byte is used for the type of frame and the LSB 4-bit and next 1-byte (total 8+4 = 12 bit)of the CAN data field is used for DLC (2^12 = 4095 data bytes). so in FF, only 6-bytes of the data can be transferred for the first time. This frame is responsible for sending the information to the receiver about the information as to how many total data bytes he is going to send.

CAN-TP: First Frame Format

CONSECUTIVE FRAME (CF): The primary task of the transport protocol or you can also CAN-TP Protocol is to transfer messages which cannot be transmitted as a single Protocol Data Unit (PDU) due to their length. Messages which contain more data that can be transmitted within a single PDU are segmented by means of the transport protocol and divided into multiple, separate PDUs. This procedure can also be implemented on the data link layer. The segmentation of the message must then be carried out in PDUs of the corresponding data link protocol.

CAN-TP: Consecutive Frame Format

In CF, the 1st byte is used for PCI byte, whereas the MSB 4-bit is defined for the type of frame and the LSB 4-bit is defined for the Sequence number. The sequence number always starts at 1 and increments with each frame sent (like as 1, 2,…, 15, 0, 1,…), with which lost or discarded frames can be detected. Each consecutive frame starts at 0, initially for the first set of the data in the first frame will be considered as 0th data. So the first set of CF(Consecutive frames) starts from “1”. There afterwards when it reaches “15”, it will be started from “0” by resetting the buffer register.

FLOW CONTROL FRAME (FC): The flow control mechanism of the CAN-TP Protocol is used to configure the sender to match the properties of the receiver (timing, available receive buffer, readiness to receive). The FCF is always sent by the receiver so that to inform about the receiver capability of how the transmitter is going to send the data. 

CAN-TP: Flow Control Frame Format

In FC, the MSB 4-bit of the 1st byte is defined as the type of frame and the LSB 4-bit defined the Flow Control Flag. 

Flow Control Flag

The Flow Control (FC) frame is sent by the receiving node to the transmitting node for flow control of the transmission. The flow control frame contains 3 bytes which together form a PCI in CAN-TP Protocol. The first byte begins in the upper four bits with a value of 3, indicates that there is flow control. In the four least significant bits of the first byte shows a Flow Status (FS). Thus the transmitter to the receiver can signal whether a segmented transmission Clear To Send (CTS), Wait or Overflow. The second byte BS stands for Block Size and shows how many consecutive frames need to be sent in one block. The last byte STmin shows the minimum separation time between consecutive frames to be noticed.

An ISO-TP frame is always 8 bytes long and unneeded bytes filled with the padding byte as 0xAA or 0x55.

Structure of TP message transfer

There are two types of data transfer methods of CAN-TP Protocol: single-frame data transmission and multiple data transmission. The single-frame data transmission (Unacknowledged Unsegmented Data Transfer) and the Multi-frame Data transmission (Unacknowledged Segmented Data Transfer). In a CAN frame, there is a maximum of 8 data bytes of user data. The data length of the ISO TP message can reach a maximum of 4095 bytes. If an ISO TP message length exceeds the data length of 8 data bytes, the UDS message must be segmented.

Single Frame Data Transmission
CAN TP Multi Frame

CAN-TP ERROR HANDLING

In CAN-TP Protocol, Both the transmitter and receiver monitors the data transmission with a timer. The receiver monitors the time required by the transmitter for sending Consecutive Frames. If this takes a long time, the transmission is aborted and data already transmitted are discarded. Similarly, the transmitter monitors the time for the receiver to send the flow control frame. Again the transmission is aborted and data already transmitted are discarded if a timeout is detected. The maximum waiting time for a frame is one second.

Basically, In addition to timing errors, errors in the message structure must be recognized. If an erroneous PDU is detected the frame is ignored or if a transmission is in progress, canceled it. Possible errors in the message structure are incorrect sequence numbers in consecutive frames, invalid message length, and invalid flow status in the flow control frames or an invalid PDU type. Unexpectedly arriving frames are always ignored, with the exception of a single frame and physically addressed the first frame. Functionally addressed first frame, consecutive frame, and flow control are always ignored.

How to send 100 bytes of data using CAN-TP Protocol?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK