This isn't optimized or fully verified, but it seems to be working with a 50Hz update rate. I'm using the Haltech V2 canbus protocol. In the Solo DL 2 i simply select the Haltech as the ECU canbus protocol and voila.
Code: Select all
function sendHaltech()
local rpm = getTimerRpm(0)
local tps = getAnalog(3)*10 --convert % to 0.10% units
local op = getAnalog(2)*6.894757*10 --convert psi to 0.1 kPa units
local ot = (((getAnalog(1) - 32)*5)/9 + 273.15)*10 --convert F to 0.1Kelvin units
local wt = (((getAnalog(0) - 32)*5)/9 + 273.15)*10 --convert F to 0.1Kelvin units
local sped = speed*1.609344*10 --convert mph to 0.1km/h units
local id = 864 --RPM, manifold pressure, TPS, coolant pressure
local data = {spu(rpm), spl(rpm), 0, 0, spu(tps), spl(tps), 0, 0}
local res = sendCAN(0, id, data)
id = 865 --fuel pressure, oil pressure, accel pedal pos, wastegate pressure
data = {0, 0, spu(op), spl(op), 0, 0, 0, 0}
res = sendCAN(0, id, data)
id = 880 --wheel speed gen., gear,
data = {spu(sped), spl(sped), spu(gear), spl(gear), 0, 0, 0, 0}
res = sendCAN(0, id, data)
id = 992 --coolant temp, air temp, fuel temp, oil temp
data = {spu(wt), spl(wt), 0, 0, 0, 0, spu(ot), spl(ot)}
res = sendCAN(0, id, data)
end