[Ovmsdev] OBD2 poller / CAN TX handling

Michael Balzer dexter at expeedo.de
Wed Jun 21 02:58:26 HKT 2017


Hi everyone,

Wolfgang (Zoe) and I just stumbled upon an ancient bug in the CAN TX
buffer handling of the OBD2 polling framework.

After checking other modules, I found the same code quite often, so
vehicles not using the poller might be affected as well.

Waiting for some TX to get finished is almost everywhere done with this
snippet:

  while (TXB0CONbits.TXREQ) {} // Loop until TX is done

Problem: this loop does not end if the PIC runs into a TX error, because
TXREQ won't get cleared then. So a TX problem with the CAN bus triggers
the watchdog reset.

Solution:

  while ((TXB0CON & 0b00111000) == 0b00001000) {} // wait for TX done /
error

This loop ends on both TX error conditions and after successful transmits.

The fix for vehicle.c is here:
https://github.com/openvehicles/Open-Vehicle-Monitoring-System/commit/13c68e95d8daec46f3aea36e4ca67f63af5bf44b

Regards,
Michael

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20170620/c3855476/attachment.htm>


More information about the OvmsDev mailing list