ECU, TCU those are both *CU?
This commit is contained in:
parent
f5f37d06ea
commit
7d1688c770
|
@ -43,18 +43,20 @@ end
|
||||||
|
|
||||||
|
|
||||||
VWTP_OUT = 0x200
|
VWTP_OUT = 0x200
|
||||||
|
cuType = 0x01
|
||||||
|
-- todo: VWTP_IN should be 0x200 + cuType maybe?
|
||||||
VWTP_IN = 0x201
|
VWTP_IN = 0x201
|
||||||
VWTP_TESTER = 0x300
|
VWTP_TESTER = 0x300
|
||||||
|
|
||||||
local ecuId = 0
|
local cuId = 0
|
||||||
|
|
||||||
function onCanHello(bus, id, dlc, data)
|
function onCanHello(bus, id, dlc, data)
|
||||||
-- here we handle 201 packets
|
-- here we handle 201 packets
|
||||||
print('Got Hello Response ' ..arrayToString(data))
|
print('Got Hello Response ' ..arrayToString(data))
|
||||||
ecuId = data[6] * 256 + data[5]
|
cuId = data[6] * 256 + data[5]
|
||||||
|
|
||||||
print('From ECU ' ..ecuId)
|
print('From ECU ' ..cuId)
|
||||||
txCan(1, ecuId, 0, { 0xA0, 0x0F, 0x8A, 0xFF, 0x32, 0xFF })
|
txCan(1, cuId, 0, { 0xA0, 0x0F, 0x8A, 0xFF, 0x32, 0xFF })
|
||||||
end
|
end
|
||||||
|
|
||||||
local sendCounter = 2
|
local sendCounter = 2
|
||||||
|
@ -74,7 +76,7 @@ function onCanTester(bus, id, dlc, data)
|
||||||
|
|
||||||
if data[1] == 0xA3 then
|
if data[1] == 0xA3 then
|
||||||
-- print ("Keep-alive")
|
-- print ("Keep-alive")
|
||||||
txCan(1, ecuId, 0, { 0xA1, 0x0F, 0x8A, 0xFF, 0x4A, 0xFF })
|
txCan(1, cuId, 0, { 0xA1, 0x0F, 0x8A, 0xFF, 0x4A, 0xFF })
|
||||||
|
|
||||||
groupIndex = groupIndex + 1
|
groupIndex = groupIndex + 1
|
||||||
if groupIndex > groupsSize then
|
if groupIndex > groupsSize then
|
||||||
|
@ -86,7 +88,7 @@ function onCanTester(bus, id, dlc, data)
|
||||||
|
|
||||||
reqFirst = 0x10 + sendCounter
|
reqFirst = 0x10 + sendCounter
|
||||||
print("Requesting next group " ..groupId .." with counter " ..sendCounter)
|
print("Requesting next group " ..groupId .." with counter " ..sendCounter)
|
||||||
txCan(1, ecuId, 0, { reqFirst, 0x00, 0x02, 0x21, groupId })
|
txCan(1, cuId, 0, { reqFirst, 0x00, 0x02, 0x21, groupId })
|
||||||
|
|
||||||
sendCounter = sendCounter + 1
|
sendCounter = sendCounter + 1
|
||||||
if sendCounter == 16 then
|
if sendCounter == 16 then
|
||||||
|
@ -98,7 +100,7 @@ function onCanTester(bus, id, dlc, data)
|
||||||
|
|
||||||
if data[1] == 0xA1 then
|
if data[1] == 0xA1 then
|
||||||
print ("Happy 300 packet")
|
print ("Happy 300 packet")
|
||||||
txCan(1, ecuId, 0, { 0x10, 0x00, 0x02, 0x10, 0x89 })
|
txCan(1, cuId, 0, { 0x10, 0x00, 0x02, 0x10, 0x89 })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -111,9 +113,9 @@ function onCanTester(bus, id, dlc, data)
|
||||||
if data[1] == 0x10 and dlc == 5 then
|
if data[1] == 0x10 and dlc == 5 then
|
||||||
ackPacket = 0xB0 + packetCounter
|
ackPacket = 0xB0 + packetCounter
|
||||||
print ("Sending ACK B1 " ..ackPacket)
|
print ("Sending ACK B1 " ..ackPacket)
|
||||||
txCan(1, ecuId, 0, { ackPacket })
|
txCan(1, cuId, 0, { ackPacket })
|
||||||
-- request first group from array
|
-- request first group from array
|
||||||
txCan(1, ecuId, 0, { 0x11, 0x00, 0x02, 0x21, groups[1] })
|
txCan(1, cuId, 0, { 0x11, 0x00, 0x02, 0x21, groups[1] })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -177,28 +179,20 @@ function onCanTester(bus, id, dlc, data)
|
||||||
if top4 == 1 then
|
if top4 == 1 then
|
||||||
ackPacket = 0xB0 + packetCounter
|
ackPacket = 0xB0 + packetCounter
|
||||||
print ("Sending payload ACK " ..ackPacket)
|
print ("Sending payload ACK " ..ackPacket)
|
||||||
txCan(1, ecuId, 0, { ackPacket })
|
txCan(1, cuId, 0, { ackPacket })
|
||||||
payLoadIndex = 0
|
payLoadIndex = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if currentState == STATE_GOT_SECOND_RESPONSE then
|
|
||||||
-- end
|
|
||||||
|
|
||||||
print('Got unexpected ' ..arrayToString(data))
|
print('Got unexpected ' ..arrayToString(data))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
canRxAdd(VWTP_IN, onCanHello)
|
canRxAdd(VWTP_IN, onCanHello)
|
||||||
canRxAdd(VWTP_TESTER, onCanTester)
|
canRxAdd(VWTP_TESTER, onCanTester)
|
||||||
|
|
||||||
|
txCan(1, VWTP_OUT, 0, { cuType, 0xC0, 0x00, 0x10, 0x00, 0x03, 0x01 })
|
||||||
txCan(1, VWTP_OUT, 0, { 0x01, 0xC0, 0x00, 0x10, 0x00, 0x03, 0x01 })
|
|
||||||
|
|
||||||
|
|
||||||
function onTick()
|
function onTick()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue