atshaw1994 has joined the chat!
I'm using Claude Sonnet 5.5 in Visual Studio and simply feeding it the result and debug logs and letting it do its thing. I'm a UI guy and don't have a very deep understanding of PCM operations.
Claude made the following edits so far:
OBDXProDevice.cs at line 381:
Code: Select all
byte[] receive = new byte[Length + 3 + offset];
receive[0] = rx[0];//Command
receive[1] = rx[1];//length
if (rx[0] == 0x09) receive[2] = rx[2];//length long frame
// Read the rest of the frame incrementally. The OS receive queue can be smaller than
// the frame (Linux tty buffers are ~4 KiB), so we can't wait for the whole frame to be queued.
int needed = Length + 1;
int received = 0;
while (received < needed)
{
Chk = await WaitForSerial(1);
if (Chk == false)
{
this.Logger.AddDebugMessage("Timeout.. no data present F");
return Response.Create(ResponseStatus.Timeout, (Message)null!);
}
int available = await this.Port.GetReceiveQueueSize();
int toRead = Math.Min(Math.Max(available, 1), needed - received);
int bytes = await this.Port.Receive(receive, 2 + offset + received, toRead);
if (bytes <= 0)
{
this.Logger.AddDebugMessage("Failed reading " + Length + " byte packet");
return Response.Create(ResponseStatus.Error, (Message)null!);
}
received += bytes;
}
KernelVerifier.cs at line 135:
Code: Select all
// The PCM can take several seconds to compute a large CRC. Wait for the reply
// instead of re-sending the query, which would desync replies and flood the PCM.
Message response = null;
for (int wait = 0; wait < 10 && response == null; wait++)
{
if (cancellationToken.IsCancellationRequested)
{
return CrcVerificationResult.Cancelled;
}
response = await this.vehicle.ReceiveMessage();
if (response == null)
{
await this.vehicle.SendToolPresentNotification();
}
}
Claude thinks:
Cause:
The P11 kernel needs more than 1 second to compute the CRC of a 64 KB range. The old code treated that 1-second silence as a timeout and re-sent the CRC query. The repeated queries flooded the PCM and desynced the replies. After 6 timeouts it gave up on each range, which is why 0x40000 down to 0x00000 failed while the earlier ranges passed.
Fix:
After sending a CRC query, the code now waits up to about 10 seconds for the reply, sending a tool-present keepalive between receives. It no longer re-sends the query while waiting.