Skip to content

Instantly share code, notes, and snippets.

@jesseproudman
Last active August 29, 2015 14:17
Show Gist options
  • Save jesseproudman/044a2dde9e6a6ee7638c to your computer and use it in GitHub Desktop.
Save jesseproudman/044a2dde9e6a6ee7638c to your computer and use it in GitHub Desktop.
P1302.lua
-- Add data channel to log misfire count
channel = addChannel("Misfire Count", 1)
misfire_count = 0
-- Sample every 1/2 second
setTickRate(2)
function onTick()
-- Request the trouble codes
data = readOBD2(03)
if data ~= nil then
-- Debugging line... Remove when functional.
println("ODB Output:" .. data)
-- According to... http://en.wikipedia.org/wiki/OBD-II_PIDs--Mode_3_.28no_PID_required.29
-- P1302 should translate to: 0001001100000010
if string.find(data, "0001001100000010") then
-- P1302 is lit. Log it...
println("ODB-II Code P1302 Found, Cycling Codes. Full code output is:"... data)
-- And clear the codes... Forget you Limp mode! BUahahahahah
txCAN(0, 1, 0, 04)
-- Increment misfire count
misfire_count += 1
setChannel(channel, misfire_count)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment