Problem with blocking readPID function

Discussion about software developed by Freematics, including Freematics Hub, Freematics Builder, Freematics Emulator GUI
Post Reply
Terraviper-5
Posts: 1
Joined: Wed Apr 14, 2021 8:42 am

Problem with blocking readPID function

Post by Terraviper-5 »

I am using Freematics OBD Adapter v2.1 to fetch rpm and speed from ECU and then forward those via Seeed CAN Bus shield to another device. This device needs to receive heartbeats at specific time intervals. Problem is that the readPID function is blocking, to mcu is waiting for car to respond (in my case for entire 90ms). Is there a way to regularly check if requested value is available and in the meantime execute other code?

Also, I have another problem, that is connected to upper one:

When car is shut down, the mcu is stuck waiting for car to respond (for 10 seconds judging by the code LONG_TIMEOUT=10000 but I never tried to wait that long). That means that last rpm value that Arduino received was cca 750rpm (not 0). This value is then displayed on my custom gauge until readPID times out, which is very annoying since its wrong value. Is there any solution to this problem? Maybe lowering TIMEOUT, can that break something?
Post Reply