harley CAN Lua

This commit is contained in:
rusefi 2021-11-22 13:00:16 -05:00
parent 9668626008
commit bc0c1a6b4a
1 changed files with 31 additions and 0 deletions

View File

@ -817,7 +817,38 @@ startPwm(outputIndex, 100, 0)
rpmLimitSetting = findSetting("compReleaseRpm", 300)
compReleaseDulationLimit = findSetting("compReleaseDur", 6000)
every200msTimer = Timer.new();
everySecondTimer = Timer.new();
-- cranking!
packet542 = {0x20, 0xc2, 0x81, 0xd9, 0x00, 0x00, 0x00, 0x00}
-- every 200ms
packet540 = {0x00, 0x00, 0x5a, 0x4c, 0xff, 0x00, 0x00, 0x00}
-- every 1000ms
packet502 = {0x01}
packet546 = {0x35, 0x48, 0x44, 0x31, 0x46, 0x48}
packet547 = {0x50, 0x41, 0x31, 0x4b, 0x42, 0x36}
packet548 = {0x33, 0x34, 0x38, 0x32, 0x32, 0x00}
function onTick()
txCan(1, 0x542, 1, packet542)
if every200msTimer:getElapsedSeconds() > 1 then
every200msTimer:reset();
txCan(1, 0x540, 1, packet540)
end
if everySecondTimer:getElapsedSeconds() > 1 then
everySecondTimer:reset();
txCan(1, 0x502, 1, packet502)
txCan(1, 0x546, 1, packet546)
txCan(1, 0x547, 1, packet547)
txCan(1, 0x548, 1, packet548)
end
rpm = getSensor("RPM")
-- handle nil RPM, todo: change firmware to avoid nil RPM
rpm = (rpm == nil and 0 or rpm)