Blog · 2026-11-10

Flow Control for Multiline Responses for Custom 15765-4 CAN messages over ELM327

Stefan Bogdanescu

Founder & Senior Architect

Flow Control for Multiline Responses for Custom 15765-4 CAN messages over ELM327

ISO 15765-4 communication over the automotive OBD-II port relies heavily on robust flow control, a mechanism distinct from standard ISO-TP single-frame exchanges. When dealing with custom Non-Standard PIDs (NVPs) like Air Intake Temperature, responses often exceed a single CAN frame. In these scenarios, the receiver must negotiate how much data to send before the sender can acknowledge receipt and request more. The ELM327 adapter simplifies this process via AT commands, but its default behavior can be opaque when troubleshooting specific flow control mismatches.

Consider a scenario where you are replicating a diagnostic tool's trace using an ELM327 adapter connected to a vehicle. You successfully configure the adapter for ISO 15765-4 at 500k baud, set the target address to 0x5F0 via ATSH5F0, and enable listening on 0x6F0 with ATCRA6F0. Upon sending a request such as 02 21 01, the vehicle responds with a header indicating 1A bytes follow. The adapter correctly forwards the first line: 6F0 10 1A 61 01 60 6B 5F 60.

However, the flow control handshake breaks down immediately after this initial segment. Instead of receiving the expected acknowledgment 5F0 30 00 01 (indicating the sender wants to continue sending the full payload), the ELM327 returns 5F0 30 00 00. This discrepancy suggests the adapter's internal state machine believes it has received a complete response, causing it to prematurely terminate the exchange and discard subsequent data frames.

The root cause often lies in the adapter's automatic formatting and flow control logic. By default, the ELM327 attempts to manage the ISO-TP window automatically. When this logic conflicts with specific NVP requirements or when the adapter misinterprets the initial response length, it generates an incorrect flow control message (zero bytes requested instead of one).

To resolve this, you must disable the adapter's automatic negotiation mechanisms to gain granular control over the session. First, turn off automatic formatting with ATCAF0. This forces you to manually specify the payload length in your request frames, ensuring the vehicle knows exactly how much data to expect for custom messages. Next, disable automatic flow control using ATCFC0.

With these settings applied, you regain full authority over the ISO-TP window negotiation. You must now construct your requests with explicit byte counts (e.g., 02 21 01 instead of relying on implicit sizing) and manually inject the flow control command 30 00 01 after receiving the initial segment.

The critical step in this manual approach is ensuring the timing between the request and the manual flow control injection matches the vehicle's expectations. If the vehicle expects a window size of one (01) but receives zero, it will not send further data. Conversely, sending too large a window can lead to buffer overflows on the vehicle side if the payload is fragmented unexpectedly.

This manual intervention is essential for custom diagnostic tools where standard OBD-II PIDs are handled separately, leaving only unique NVPs to be queried. While ISO-TP generally handles flow control transparently, custom implementations on microcontrollers or specific ECU logic may require precise adherence to the negotiated window size. Disabling automation allows you to mirror the exact behavior of professional diagnostic tools by explicitly managing the 03 (ACK) and 30 (FC) frames.

If you are developing a library for vehicle diagnostics in PHP, you might consider leveraging existing abstractions that handle raw ISO-TP framing. For instance, packages available from LaravelCompany often provide robust examples of handling serial communication and custom protocol logic, which can be adapted to manage these manual ISO-TP handshakes effectively without relying on the ELM327's automatic interpretation layers.