sendCounter progress
This commit is contained in:
parent
5e7272c33d
commit
713f5a901d
|
@ -59,7 +59,7 @@ function onCanHello(bus, id, dlc, data)
|
||||||
txCan(1, cuId, 0, { 0xA0, 0x0F, 0x8A, 0xFF, 0x32, 0xFF })
|
txCan(1, cuId, 0, { 0xA0, 0x0F, 0x8A, 0xFF, 0x32, 0xFF })
|
||||||
end
|
end
|
||||||
|
|
||||||
local sendCounter = 2
|
local sendCounter = 0
|
||||||
local packetCounter = 1
|
local packetCounter = 1
|
||||||
local payLoadIndex = 0
|
local payLoadIndex = 0
|
||||||
|
|
||||||
|
@ -69,6 +69,15 @@ local groupsSize = 3
|
||||||
|
|
||||||
local groupIndex = 1
|
local groupIndex = 1
|
||||||
|
|
||||||
|
function nextReq()
|
||||||
|
local result = 0x10 + sendCounter
|
||||||
|
sendCounter = sendCounter + 1
|
||||||
|
if sendCounter == 16 then
|
||||||
|
sendCounter = 0
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
function onCanTester(bus, id, dlc, data)
|
function onCanTester(bus, id, dlc, data)
|
||||||
-- here we handle 300 packets
|
-- here we handle 300 packets
|
||||||
|
|
||||||
|
@ -83,24 +92,20 @@ function onCanTester(bus, id, dlc, data)
|
||||||
groupIndex = 1
|
groupIndex = 1
|
||||||
end
|
end
|
||||||
groupId = groups[groupIndex]
|
groupId = groups[groupIndex]
|
||||||
print (groupIndex .." " ..groupId)
|
print ("KA " .. groupIndex .." " ..groupId)
|
||||||
|
|
||||||
|
|
||||||
reqFirst = 0x10 + sendCounter
|
reqFirst = nextReq()
|
||||||
print("Requesting next group " ..groupId .." with counter " ..sendCounter)
|
print("Requesting next group " ..groupId .." with counter " ..reqFirst)
|
||||||
txCan(1, cuId, 0, { reqFirst, 0x00, 0x02, 0x21, groupId })
|
txCan(1, cuId, 0, { reqFirst, 0x00, 0x02, 0x21, groupId })
|
||||||
|
|
||||||
sendCounter = sendCounter + 1
|
|
||||||
if sendCounter == 16 then
|
|
||||||
sendCounter = 0
|
|
||||||
end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if data[1] == 0xA1 then
|
if data[1] == 0xA1 then
|
||||||
print ("Happy 300 packet")
|
print ("Happy 300 packet, follow-up...")
|
||||||
txCan(1, cuId, 0, { 0x10, 0x00, 0x02, 0x10, 0x89 })
|
txCan(1, cuId, 0, { nextReq(), 0x00, 0x02, 0x10, 0x89 })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,7 +120,7 @@ function onCanTester(bus, id, dlc, data)
|
||||||
print ("Sending ACK B1 " ..ackPacket)
|
print ("Sending ACK B1 " ..ackPacket)
|
||||||
txCan(1, cuId, 0, { ackPacket })
|
txCan(1, cuId, 0, { ackPacket })
|
||||||
-- request first group from array
|
-- request first group from array
|
||||||
txCan(1, cuId, 0, { 0x11, 0x00, 0x02, 0x21, groups[1] })
|
txCan(1, cuId, 0, { nextReq(), 0x00, 0x02, 0x21, groups[1] })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue