# computing the parity of diagnostic requests' frame id

I am implementing a LIN master, developing all the aspects of the LIN protocol I need, using a UART device (capable to send break).

The question is about the doubt to compute the parity bits in order to send the protected identifier on the bus (as one does for any unconditional frame)

As LIN_Specification_Package_2.2A states:

2.3.1.3 Protected identifier field

A protected identifier field consists of two sub-fields; the frame identifier and the parity.

Bits 0 to 5 are the frame identifier and bits 6 and 7 are the parity.

Frame identifier

Six bits are reserved for the frame identifier, values in the range 0 to 63 can be used.

The frame identifiers are split in three categories:

• Values 0 to 59 (0x3B) are used for signal carrying frames,

• 60 (0x3C) and 61 (0x3D) are used to carry diagnostic and configuration data,

• 62 (0x3E) and 63 (0x3F) are reserved for future protocol enhancements.

Parity

The parity is calculated on the frame identifier bits as shown in equations (1) and (2):

P0 = ID0 ^ ID1 ^ ID2 ^ ID4 (1)

P1 = ~(ID1 ^ ID3 ^ ID4 ^ ID5) (2)

How do I compute the protected id in case of diagnostic requests, as I couldn't find any evidence in the official documentation?

In case of diagnostic master request, the frame id is 0x3C: the protected ID to be sent is still 0x3C (P0 = 0, P1 = 0).

In case of diagnostic slave response, the frame id is 0x3D: the protected ID computed should be 0x7D (P0 = 1, P1 = 0).

So, in short, as a LIN master should I send 0x7D as protected identifier (raw value on the bus line) to let the slave reply?

LIN Protocol and Physical Layer Requirements

LIN Message Frame

• Details of what you are talking about at the start of the question will help. A link or few to relevant documentation will also help. You mention LIN in passing. May 28, 2020 at 3:40
• Agree - what's the context here?
– RJR
May 28, 2020 at 7:34
• Hi, sorry for not being clear. I am implementing a LIN master, developing all the aspects of the LIN protocol I need, using a UART device (capable to send break). The question is about the doubt to compute the parity bits in order to send the protected identifier on the bus (as one does for any unconditional frame). May 28, 2020 at 13:58
• I have no experience with LIN - but reading what you say above and skimming through a version of the LIN SPECIFICATION PACKAGE (that you should have provided a reference to, or to one relevant to you) it seems that you "have it backwards". | To me the instruction "In case of diagnostic master request, the frame id is 0x3C: the protected ID to be sent is still 0x3C (P0 = 0, P1 = 0)." sounds as though your master should send 03xC. May 28, 2020 at 23:39
• Hi Russell, thanks for editing the question adding references. I definitely learn something. My doubt was on the frame id of the slave response but re-reading the quoted lines I'm pretty confident that I should trasform 0x3D (adding the parity bits) into 0x7D and send it on the bus as protected identifier. As I'll receive a LIN slave board, I will be able to test this out and confirm this as answer myself. Thank you all. May 29, 2020 at 7:30