Serial comunication k-line

good morning. I am trying to understand about arduino serial communication with Honda k-line protocol. here I include a link to github link that discusses the communication. here I want to ask if there are any friends who can help me to better understand how to generate checksum value from the code snippet in github. so here is an example of the code:
DESCRIPTION:

  • Request = 72 AA BB CC CS
  • 72 = Request Header Code
  • AA = Number of Bytes (including the Checksum)
  • BB = Query Table
  • CC = Table
  • CS = Checksum

CHECKSUM

  • Usually to make a data table can be started from 00 to FF. With code 72 05 71 ZZ CS
  • Where ZZ = data table 00 to FF and CS = Checksum
  • The formula checksum = 100 - (sumbyte and FF)
  • For example the data request Table 13 = 72 05 71 13 CS Then the checksum value = 100 - ((72 + 05 + 71 + 13) AND FF) , result CS = 05
  • So the data request table 13 = 72 05 71 13 05
    how can i generate the checksum value 05 from the table
byte cs = (0x100 - 0x05 - 0x71-0x13) & 0xFF;

not compiled.

Thank you for your response, but here I only quote the code from github. I have included the link above. There is a code snippet to find out the correct checksum value so that serial communication with k-line gets a valid response. However, I don't understand where the value of 0x05/(05) comes from, which is obtained from the formula he explained in his post. What I want to know is how to generate the checksum value from the formula he gave :folded_hands:

Not sure what you are asking? The CS value is the calculated value.

Usually one composes a message (called request in Honda_Keihin_KLine_Protocol/REQUEST - RESPONSE ECU HONDA K25 901.txt at main · AutotronicCommunity/Honda_Keihin_KLine_Protocol · GitHub) without the CS and calculates the CS. In your case this is already included in the request.

It is true what you said, sir. It's just that the checksum value in the file is generated/formulated by him. Here I want to understand how the person can generate the checksum value using the formula he provided. This is very important in developing the program code that I am trying to develop, it's just that here I can't understand how to calculate the formula. The person actually has a TEFA SOLUSINDO YouTube channel. It's just that in his videos he never really explains the process clearly. He seems to want his viewers to collect puzzles and find their own solutions to breaking communication with the ECU

as you know the .txt file included in the post is a request for live data on the ecu. to be able to display standard sensor values and engine speed. it is important to understand the formula to handle more requests. for example to clear DTC. to read the ECU id. and also to find out the SMARTKEY ID that can be used for damaged / lost remote vehicles and don't forget the remote id. if you don't know the SMARTKEY id then it will be difficult to register a new remote. automatically have to replace the SCU and ECU One package. and the price is quite high. therefore I want to make an affordable tool to be able to handle the read data procedure on the ECU. for very urgent matters :folded_hands::folded_hands: I hope you understand the meaning of what I am trying to explain

The basics in below demo; I've picked Request : [72, 05, 71, 17, 01] from the link.

uint8_t request[5];

void setup()
{
  Serial.begin(115200);
  while (!Serial) {}

  Serial.println(F("Composing request"));
  // header
  request[0] = 0x72;
  // length
  request[1] = 0x05;
  // query table
  request[2] = 0x71;
  // table
  request[3] = 0x17;

  Serial.println(F("Calculating CS"));
  uint8_t cs = 0;
  for (uint8_t cnt = 0; cnt < request[1]; cnt++)
  {
    cs -= request[cnt];
  }
  if (cs < 0x10) Serial.print("0");
  Serial.println(cs, HEX);
}


void loop()
{
}

I hope this makes it clear.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.