B6 TCU TP works nicely without codes

This commit is contained in:
rusefillc 2023-02-03 19:07:20 -05:00
parent b37b415939
commit eeebde9dc7
1 changed files with 17 additions and 3 deletions

View File

@ -48,7 +48,7 @@ function onCanHello(bus, id, dlc, data)
print('Got Hello Response ' ..arrayToString(data)) print('Got Hello Response ' ..arrayToString(data))
cuId = data[6] * 256 + data[5] cuId = data[6] * 256 + data[5]
print('From ECU ' ..cuId) print('From *CU ' ..cuId)
out = { 0xA0, 0x0F, 0x8A, 0xFF, 0x32, 0xFF } out = { 0xA0, 0x0F, 0x8A, 0xFF, 0x32, 0xFF }
print("Saying hello " .. arrayToString(out)) print("Saying hello " .. arrayToString(out))
txCan(1, cuId, 0, out) txCan(1, cuId, 0, out)
@ -94,9 +94,15 @@ function requestEraseCodes()
print("Requesting to Erase Code(s)") print("Requesting to Erase Code(s)")
end end
function scheduleTpRestart()
byeByeStateCounter = 3 * tickRate
end
keepAliveCounter = 0
function onCanTester(bus, id, dlc, data) function onCanTester(bus, id, dlc, data)
-- here we handle 300 packets -- here we handle 300 packets
scheduleTpRestart()
print('Got from tester ' ..arrayToString(data)) print('Got from tester ' ..arrayToString(data))
if data[1] == 0xA3 then if data[1] == 0xA3 then
@ -107,6 +113,14 @@ function onCanTester(bus, id, dlc, data)
if withErrorCodes > 0 then if withErrorCodes > 0 then
requestEraseCodes() requestEraseCodes()
else
keepAliveCounter = keepAliveCounter + 1
if keepAliveCounter > 4 then
requestErrorCodes()
keepAliveCounter = 0
end
end end
return return
@ -121,7 +135,6 @@ function onCanTester(bus, id, dlc, data)
if data[1] == 0xA8 then if data[1] == 0xA8 then
print ("They said Bye-Bye") print ("They said Bye-Bye")
byeByeStateCounter = 3 * tickRate
return return
end end
@ -198,6 +211,7 @@ function onTick()
end end
if byeByeStateCounter == 1 then if byeByeStateCounter == 1 then
scheduleTpRestart()
startTp() startTp()
end end