only:canam

only:proteus_f7
This commit is contained in:
Andrey 2023-09-21 22:06:44 -04:00
parent d839977eb7
commit 7645bfe0e7
3 changed files with 30 additions and 24 deletions

View File

@ -27,29 +27,7 @@ void setMaverickX3() {
#endif // HW_PROTEUS #endif // HW_PROTEUS
#if HW_PROTEUS #if HW_PROTEUS
strncpy(config->luaScript, GET_BIT_RANGE_LSB TWO_BYTES_LSB PRINT_ARRAY SET_TWO_BYTES_LSB R"( #include "canam_2021.lua"
isUseful = Timer.new()
isUseful : reset()
function onTick()
rpm = getSensor("RPM")
vbat = getSensor("BatteryVoltage")
-- print (vbat .. " " .. rpm)
if (vbat < 8) or (rpm > 200) then
-- keep alive if USB hooked up
isUseful : reset()
end
if (isUseful : getElapsedSeconds() > 17) then
mcu_standby()
end
end
)", efi::size(config->luaScript));
#endif // HW_PROTEUS #endif // HW_PROTEUS
} }

View File

@ -0,0 +1,23 @@
strncpy(config->luaScript, GET_BIT_RANGE_LSB TWO_BYTES_LSB PRINT_ARRAY SET_TWO_BYTES_LSB R"(
isUseful = Timer.new()
isUseful : reset()
function onTick()
rpm = getSensor("RPM")
vbat = getSensor("BatteryVoltage")
-- print (vbat .. " " .. rpm)
if (vbat < 8) or (rpm > 200) then
-- keep alive if USB hooked up
isUseful : reset()
end
if (isUseful : getElapsedSeconds() > 17) then
mcu_standby()
end
end
)", efi::size(config->luaScript));

View File

@ -36,13 +36,17 @@ end
totalEcuMessages = 0 totalEcuMessages = 0
totalTcuMessages = 0 totalTcuMessages = 0
totalDropped = 0
totalReplaced = 0
function printAndDrop(bus, id, dlc, data) function printAndDrop(bus, id, dlc, data)
print('Dropping ' ..arrayToString(data)) print('Dropping ' ..arrayToString(data))
totalDropped = totalDropped + 1
end end
function onAnythingFromECU(bus, id, dlc, data) function onAnythingFromECU(bus, id, dlc, data)
totalEcuMessages = totalEcuMessages + 1 totalEcuMessages = totalEcuMessages + 1
print('from ECU ' .. id .. " " .. arrayToString(data) .. " dropped=" .. totalDropped .. " replaced " .. totalReplaced)
txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU
end end
@ -54,6 +58,7 @@ end
MOTOR_1 = 0x282 MOTOR_1 = 0x282
function interceptAndReplaceContent(bus, id, dlc, data) function interceptAndReplaceContent(bus, id, dlc, data)
totalReplaced = totalReplaced + 1
rpm = 200 rpm = 200
data[3] = rpm data[3] = rpm
-- send adjusted packet into the other bus -- send adjusted packet into the other bus
@ -73,6 +78,6 @@ everySecondTimer = Timer.new()
function onTick() function onTick()
if everySecondTimer:getElapsedSeconds() > 1 then if everySecondTimer:getElapsedSeconds() > 1 then
everySecondTimer:reset() everySecondTimer:reset()
print("Total from ECU " .. totalEcuMessages .. " from TCU " .. totalTcuMessages) print("Total from ECU " .. totalEcuMessages .. " from TCU " .. totalTcuMessages .. " dropped=" .. totalDropped .. " replaced " .. totalReplaced)
end end
end end