Only Works on first run

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="http://autosportlabs.net/RaceCapturePro_Lua_Scripting">Lua Scripting Guide</a>

Moderators: JeffC, stieg

Post Reply
z28pwr
Posts: 10
Joined: Wed Jan 18, 2017 4:49 am

Only Works on first run

Post by z28pwr »

I'm just getting started with Race Capture and want to output the data to the console to later build other scripts and when the script runs the first time it shows the correct value which is 0 for RPM and 127 for engine temperature but then it states that it can't read the values for several iterations. The dashboard seems to show them perfectly fine, any ideas as to why they show up fine initially and then I get a bunch of errors?


Image
Straight roads are for fast cars turns are for fast drivers

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Calling readOBD2() might return a nil value, meaning no data was returned. You should first check if the value is present before doing anything with it.

e.g.

if engine ~= nil then
println('engine value ' ..engine)
end

Hope that helps!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

z28pwr
Posts: 10
Joined: Wed Jan 18, 2017 4:49 am

Post by z28pwr »

Thanks Brent, you are correct the issue is that at times it's failing to obtain a reading for that PID and returning the nil value.

I modified the script to account for a nil value but why am I seeing so many OBD2: PID read fail errors? I seem to get one every 3 seconds or so and it does'n t matter what PID I'm checking either. Is this a bug?
Straight roads are for fast cars turns are for fast drivers

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

A PID read error means RCP did not receive a response from the ECU. Worth noting, the ECU can only service one PID request at a time.

Do you have OBDII channels also enabled in the top level configuration?

If you don't have the top level OBDII configuration enabled, could you enable that for say, RPM and engine temperature and disable your script temporarily? Do you still get the PID reading errors?
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

z28pwr
Posts: 10
Joined: Wed Jan 18, 2017 4:49 am

Post by z28pwr »

brentp wrote:A PID read error means RCP did not receive a response from the ECU. Worth noting, the ECU can only service one PID request at a time.

Do you have OBDII channels also enabled in the top level configuration?

If you don't have the top level OBDII configuration enabled, could you enable that for say, RPM and engine temperature and disable your script temporarily? Do you still get the PID reading errors?
Brent, I did have two OBD2 channels enabled (5&12). I removed the script, rebooted rc and still saw the PID errors. I then removed the Channels and the errors went away. Does that mean that I have an issue?
Straight roads are for fast cars turns are for fast drivers

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

With your script removed, try to re-enable just RPM. Ensure:
* CAN and OBDII switches are enabled
* CAN is set to 500K baud

after writing the configuration check OBDII operation with a running engine. Do you see data update in the dashboard and/or messages in the log?
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply