domnulvlad/KLineKWP1281Lib

Long time to switch between modules

Closed this issue · 9 comments

I found that switching between ECU and Cluster modules (closing one connection, waking another module and connecting) takes about 12000ms from read to read. Is there a way to do it quicker?

I just tried it and indeed it is slow, but that is just how this protocol is.

First it takes 2 seconds to perform the 5baud init, then it takes some time to get the module's info (which cannot be skipped), and then when you disconnect, it is required to wait 1 second before connecting to something else (actually it happens automatically with the connect() function when an attempt fails).

And also the module's baud rate influences the time taken, for example data will be much quicker on a 10400 baud device than on 4800. Again, you can't change any of this.

On my setup I have a cluster at 10400 and radio at 9600, and I can get about one measurement every 8.5 seconds if I switch between modules. Unfortunately there is nothing you can do differently with KWP1281.

Personally, I would say that if you have a project where you show data on a screen, you should have a separate page for each module, not trying to mix multiple modules at once, because you can see how slow it is. Every connection attempt has its own "overhead".

You can technically shave off a few seconds by saving a 5baud attempt if you manually delay about 1s between disconnect() and connect(), or you could find some other delay that still works.

No, the protocol only supports one connection at a time. Everything happens on a single wire so there is nothing to do.

You could actually maybe get to the connector on the CCM and cut the K-line from the bus so it isn't connected to the other K-lines anymore. Then you could use a dedicated adapter for the CCM and another one for the rest of the modules.

I haven't done it before because I only have one adapter but I think you would have to use you own custom5baudWaitFunction, in which you update the other connection so it doesn't break while the code is delay()-ing. Also you should avoid the normal connect() function and instead use attemptConnect() so you can avoid the other connection breaking while one is waiting after a failed attempt.

I will try to write such an example for two adapters when I have the time.

Ok. So for the future, the most reliable way to get your door data to update quickly is to isolate the CCM's K-line and use a separate adapter. Then of course you won't be able to diagnose the CCM with VCDS, you could maybe add a hidden switch that reconnects it to the K-line bus if you want.

Hi again, @emtepe35. If you are still interested in this, I have written up a little page about your issue here with a bit more explanations. The conclusion is the same, there is no way to do what you wish to do without having to modify something, but if you are ok with modifications, then the solution is simple enough.

I have updated that wiki page. I had completely overlooked the multitasking capabilities of the ESP32, which would be the best solution to your problem. No need for any additional microcontrollers.