Hello! I'm using a very simple board with a F405RGT6 cpu, and the rusefi.snapshot.f407-discovery image. Everithing is working good. I wanna try the LUA scripting, but I stucked in the very beginning
I tried to read a sensor value and print it to first test, but I only get nil not a value. I tried clt, Tps1, rpm, but no one working
function onTick()
clt = getSensor("Clt")
print(clt)
end
my queston is: the LUA srcipting all features is available in all the pre compiled images?
No, I have a stand alone ETB controller. In the LUA script example files I see somebody create the can output script for megasquirt, and I think if the rpm signal and the ETB Position Target can work from the broadcansted can bus massage, my little board will be a fully implemented can bus ETB controller. Right now I use the setetbaddpercent lua script to control the idle with ETB from the ecu pwm idle signal
The rpm signal over can bus not working, but if I connect the Rusefi trigger input with the megasquirt tachometer output, and connect each together with can, the megasquirt can work with a full integrated can bus DBW controller, on the DBW controller run RusEfi code.
LUA script:
-- DBW protocol for legacy standalone systems
BASE_CAN_ID = 256
setTickRate(100)
-- MOTOROLA order, MSB (Most Significant Byte/Big Endian) comes first
function setTwoBytesMsb(data, offset, value)
value = math.floor(value)
data[offset + 1] = value >> 8
data[offset + 2] = value & 0xff
end
function getTwoBytesMSB(data, offset, factor)
return (data[offset + 1] * 256 + data[offset + 2]) * factor
end
function printPacket(bus, id, dlc, data)
local TpsTarget = getTwoBytesMSB(data, 0, 1)
TpsTarget = TpsTarget/1024 * 1000
TpsTarget = TpsTarget / 10
local Pedal = getSensor("AcceleratorPedal")
Throttle = TpsTarget - Pedal
setEtbAdd(Throttle)
end
function onTick()
local ppsValue = getSensor("AcceleratorPedal")
ppsValue = (ppsValue == nil and 0 or ppsValue)
local TPS = getSensor("Tps1")
TPS = (TPS == nil and 0 or TPS)