Subject: | [PATCH] Make ReadResponse() more robust |
Date: | Tue, 27 May 2014 09:43:33 -0500 |
To: | bug-Device-ELM327 [...] rt.cpan.org |
From: | Jason McCarver <slam [...] parasite.cc> |
Hello,
I was trying to use Device::ELM327 with obdgpslogger's obdsim which
simulates an ELM327 device, see: http://icculus.org/obdgpslogger/
ReadResponse() was failing to read the response correctly from obdsim
as it seemed it would get an empty read (0 bytes returned) before the
actual end of the response. This would cause it to fail to even detect
obdsim as an ELM327 device.
I have attached a patch that changes ReadResponse() to (hopefully) be
more robust. Instead of a zero-byte read signaling the end of the
response, it watches for the '>' character on a line by itself.
In the case of zero-byte reads, ReadResponse() will retry each read up
to a maximum number of retries. There is an increasingly longer delay
between each retry in the hopes that we can recover quickly in the case
of a small ECU delay but accommodate for a longer ECU delay.
I've run this patch successfully against obdsim and against an actual
ELM327 device (over USB) that I have. It was not attached to a car at
the time however so testing was limited.
Thanks,
Jason
Message body is not shown because sender requested not to inline it.