Decoding Trouble Codes with Kiwi 2 WiFi OBD2

The Kiwi 2 Wifi Obd2 adapter allows users to read and clear Diagnostic Trouble Codes (DTCs) from their vehicles. This process involves communicating with the vehicle’s Engine Control Unit (ECU) using specific protocols, primarily differentiated between Controller Area Network (CAN) and non-CAN communication. This article delves into a pseudo-code example demonstrating how the Kiwi 2 might handle requesting and interpreting these codes.

Understanding the Code: Requesting Trouble Codes

The provided pseudo-code outlines a function called RequestTroubleCodes, which aims to retrieve up to three DTCs from the vehicle’s ECU. The logic branches based on the communication protocol in use (determined by ConnectProtocol).

For non-CAN protocols, the code sends a request command (“03”) followed by a carriage return (0x0d). It then enters a loop, waiting for and reading the response byte-by-byte. Each byte represents a character of the DTC. Spaces delimit individual codes. The code meticulously reads each character of each trouble code, assigning them to variables b0 through b11. This process repeats until three potential codes are read or the end of the response is reached.

For CAN protocols, the process differs slightly. If fewer than three trouble codes are expected, the code sends a similar request and parses the response similarly to the non-CAN method. However, if three or more codes are anticipated, the code waits for a colon (‘:’) indicating the start of the DTC list. It then reads the number of trouble codes and proceeds to read each code character by character, separated by spaces, until all codes are retrieved. The process then repeats, searching for another colon and subsequent codes, until the end of the response is reached.

Finally, regardless of the protocol, the received byte data is stored in global variables (errb0 to errb11) for further processing. The function concludes by waiting for an “OK>” prompt, signaling the completion of the request.

Deciphering the Code Prefix

Another function, ErrorCodePrefix, takes the first byte (b0) of a DTC and determines its corresponding prefix. This prefix indicates the system or subsystem related to the error code. For instance, ‘P’ signifies Powertrain, ‘C’ represents Chassis, ‘B’ denotes Body, and ‘U’ stands for Network. The numeric character preceding the letter (0-3) further categorizes the code within its respective system. This function translates the hexadecimal value of b0 into its corresponding alphanumeric prefix.

Identifying the Communication Protocol

The GetProtocol function determines whether the vehicle uses the CAN protocol. It sends a specific command (“atdp”) followed by a carriage return to query the protocol. The response is then parsed; if the string “157” is found, the function returns 1, indicating CAN communication. Otherwise, it returns 0, signifying a non-CAN protocol. Like the previous functions, it waits for an “OK>” prompt before returning.

Conclusion

The provided pseudo-code illustrates the intricate process of requesting, receiving, and interpreting DTCs using a Kiwi 2 WiFi OBD2 adapter. The code highlights the differences in handling CAN and non-CAN protocols, providing insights into how diagnostic tools interact with modern vehicles. By understanding this fundamental communication process, users can effectively utilize the Kiwi 2 to diagnose and troubleshoot vehicle issues.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *