Skip to content

Fix send delay for bluetooth/Raspberry Pi#162

Merged
alistair23 merged 1 commit into
brendan-w:masterfrom
zaneclaes:zkc-send-speed
Nov 3, 2019
Merged

Fix send delay for bluetooth/Raspberry Pi#162
alistair23 merged 1 commit into
brendan-w:masterfrom
zaneclaes:zkc-send-speed

Conversation

@zaneclaes

@zaneclaes zaneclaes commented Oct 29, 2019

Copy link
Copy Markdown

This corrects the following issue, detected on a Raspberry Pi connecting via Bluetooth (though it may not be exclusive to this case): #160

The root cause was that the send command was attempting to retrieve responses from the OBD adapter before they were available for the startup commands (likely due to latency over Bluetooth or some slowness with the dongle itself). I verified that each of ATH1, ATL0, and AT RV would not work on my Raspberry Pi 4 with bluetooth without using at least a 0.1 second delay.

My first thought was to use the fast=False configuration value to add a delay to __send(), but on experimentation I discovered that this created an artificial delay which was unnecessary for retrieving values later (such as SPEED). Instead, I modified the __send() function to retry the read() if the response was empty for up to one second. AFAIK, this should not be problematic in that a response is always expected by any monitoring commands sent to the OBDII adapter.

... but I defer to the maintainers, as I only just started reading about the OBDII/ELM327 protocol specifics today.

// fyi @alistair23 @ajalberd

@ajalberd

Copy link
Copy Markdown

It works now with fast=false, and a no voltage check. Thank you!

@zaneclaes

Copy link
Copy Markdown
Author

@ajalberd glad to hear it! I also packaged it up as a Docker container to run on my Raspberry Pi Kubernetes cluster, along with Prometheus exporting, if you're curious: https://github.com/zaneclaes/node-pi-obd-monitor

@alistair23

Copy link
Copy Markdown
Collaborator

This looks fine to me. It won't interfere with already working systems but should help fix the RaspberryPi Bluetooth issue.

@alistair23
alistair23 merged commit b2d65f6 into brendan-w:master Nov 3, 2019
@zaneclaes
zaneclaes deleted the zkc-send-speed branch November 5, 2019 22:23
@pasipiya

pasipiya commented Sep 9, 2020

Copy link
Copy Markdown

Can anyone please guide me ho to change "fast=False" I am using raspberry pi 4. But still I can't connect my bluetooth OBD adaper using python-obd connector.
Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants