LIN Network Diagnostics Made Easy: Understanding Diagnostic Frames
Tags: automation, lin, tutorial, learning
Published: 2023-10-18 09:29:37

Hello Readers, 👋😍
My name is Aravind B N, and I work at "Luxoft India" as a Junior Software Developer. Luxoft has given me several opportunity to work on various projects, which has inspired me to discuss the important processes involved in developing a LIN (Local Interconnect Network) protocol in Scheduling, and Message Types in [part 4](https://dev.to/arvind_b_n_luxoft/exploring-lin-protocol-part-4-understanding-message-types-and-scheduling-2fpa). This is part 5 of the LIN protocol. Here we will discuss the Diagnostic Frames in-detail.

**Diagnostic Frame**

**_Master Request Frame / Slave Response Frame_**
The protocol defines diagnostic frames: the grasp request frame and the slave reaction body. They are described based totally at the ISO 15765-2 delivery and on uniform diagnostic offerings (UDS) according with ISO 14229. A grasp request frame is normally used as a diagnostic request or to configure slaves. A slave reaction frame is used as a diagnostic response.

_Functionality_
The two diagnostic frames, like unconditional, event triggered, and sporadic frames, are made up of a Frame Header and a Frame Response. The master transmits both the frame header and the frame response in the event of a master request frame (diagnostic request). ID=0x3C is used to convey the frame header. The master delivers the frame header and the diagnosed slave provides the frame response in the case of a slave response frame (diagnostic response). ID=0x3D is given in the frame header (see figure: Diagnostic Principle).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mvw2h5ezpdzpck5h555u.png)

figure: Diagnostic Principle

_Diagnostic Frame: Master Request_

- Reserved unconditional frame with ID = 0 * 3C
- Transmission of the header and the response by the master
- Function: Initiate a diagnostic process (diagnostic request)
- Segmented diagnostic request is possible.

_Diagnostic Frame: Slave Request_

- Reserved unconditional frame with ID=0x3D
- Transmission of the header by the master
- Transmission of the response by the relevant slave
- Function: Answer to the diagnostic request (diagnostic response)
- Segmented diagnostic response is possible

**Node Adress for Diagnostics (NAD)**
The ISO shipping protocol defines the shape of the Frame Response and the capability of the information it consists of. The first byte of the frame response always consists of — regardless of whether or not it's miles a master frame reaction or slave frame response — a formal node cope with (NAD) of the slave to be configured or diagnosed.

**Protocol Control Information (PCI)**
The second byte of the frame response (PCI) gives records at the transfer mode. The ISO delivery protocol defines an unsegmented and a segmented facts switch. An unsegmented information transfer is finished with one master request frame and one slave reaction body (SF). For example, Diagnostic Requests that are used to configure a node are typically unsegmented.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w7grj0ea8lkpzoy1dqq4.png)
Figure: Unsegmented Data transfer

**Frame Types**
Segmented facts switch is used if eight records bytes are inadequate to transmit the diagnostic information. In this situation, the information are segmented, i.E. Allotted to multiple frames. The first frame of the sort of phase collection is referred to as the first frame (FF), while all subsequent frames are consecutive frames (CF). The length of the complete facts block is shown in the FF.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w7jci7644p1k819del8b.png)
Figure: Segmented Data transfer

**Service Identifier (SID)**
The master makes use of what's called the service identifier (SID) to communicate to the slave which diagnostic carrier ought to be executed (see figure: Service Identifier). The 1/3 byte is provided for this within the diagnostic request. In the slave reaction body, the so-referred to as RSID is used as opposed to the SID. The diagnostic offerings are described in the following specification: Node Configuration and Identification.

```
Frames {
  Diagnostic_Frame: 60, MyECU, 8 {
    Diagnostic_Signal_1, 0 ;
    Diagnostic_Signal_2, 8 ;
    Diagnostic_Signal_3, 16 ;
    Diagnostic_Signal_4, 24 ;
    Diagnostic_Signal_5, 32 ;
    Diagnostic_Signal_6, 40 ;
    Diagnostic_Signal_7, 48 ;
    Diagnostic_Signal_8, 56 ;
  }
}
```
A diagnostic frame in the LIN (Local Interconnect Network) protocol is a specific type of frame used for diagnostic and configuration purposes.

- Frame Definition: In the LIN Description File (LDF), you define a diagnostic body inside the "Frames" section. You supply it a call, assign a unique body ID, specify the transmitting node, and define its duration in bytes.
- Frame ID: The frame ID is a numeric identifier that distinguishes this frame in the LIN community. For diagnostic frames, IDs normally variety from 60 to sixty one in LIN 2.Zero and later versions.
- Transmitting Node: This is the LIN node responsible for sending the diagnostic body onto the LIN bus. It can be the master or a particular slave node.
- Frame Length: This specifies the period of the diagnostic body in bytes. It suggests what number of bytes of information the frame can bring.
- Signals: Within the diagnostic frame, you could include one or more indicators. These indicators represent particular portions of diagnostic or configuration records that need to be communicated between nodes.
- Bit Positions: Each signal inside the diagnostic frame is assigned a beginning bit position. This suggests where within the frame's information bytes the signal's facts starts.

Diagnostic frames are important for studying diagnostic statistics from both master and slave nodes in the LIN network. They provide a standardized manner to alternate diagnostic and configuration data, making it simpler to diagnose and screen the network's health and standing. The LIN Description File (LDF) serves as a configuration record to outline and manage those frames and their associated signals.

This is Fifth part of the LIN Protocol next article based on Data Protection process LIN protocol alone with example.

Do let me know if you have any queries in the comments below.

Thanks for reading.