Help Please - Numerous ShiftX2 Faults
Posted: Mon Mar 04, 2019 11:14 pm
Hello, can't seem to get ShiftX2 to behave correctly after numerous hours fiddling with it. I suspect it comes down to Lua script problems, but I'm not sure since what I'm trying is essentially a copy and paste sample script...nothing fancy.
Background:
-RC/Track Mk2
-1.14.6 Android app
-Use 2 different android devices, same result (side note Samsung S7, Android 8.0 RC app never closes properly, unrelated)
-2.13.5 firmware
-direct CAN mapped on channels 1 & 2 from car, works fine
-ShiftX2 on CAN 2 using RJ45 splitter
-Disco Light Demo script works fine, starts immediately on RC hardware power up (no app) as intended
-Install allows RC & ShiftX2 to power up before CAN buses are alive
-Struggled with this "bug" - still no feedback viewtopic.php?t=6082
-Portion of script works fine, see below
Faults:
-Won't start on RC hardware power up, only starts after opening app and hitting Run, or flashing a new write
-Once started, RPM linear graph, and RHS Alert 0 (Oil Temp) works fine. LHS Alert 1 will not start or update.
--------This is true no matter what channel I pull into Alert 1, and Water temp updates no problem in the Dashboard
--------If I go to CAN mapping and open the CAN channel edit dialog box for Water and then hit the check mark to close out the window (no edits made), then and only then will Alert 1 turn on and receive a single value. Alert 1 value will never update again until I pretend to edit the CAN mapping again.
-ShiftX2 button press only randomly will report in the log, sometimes 0.0 or 1.0, far from consistent
Other Info:
-on Write reports 16Kb memory used, seems high for small script. What is included in that memory value?
-Flashing a new write will often cause the Wifi connection to be killed and reports back "Port Closed," typically takes multiple tries to achieve successful write
-Using the Poll feature often creates hangs and generates various error messages, kills connection, etc.
Background:
-RC/Track Mk2
-1.14.6 Android app
-Use 2 different android devices, same result (side note Samsung S7, Android 8.0 RC app never closes properly, unrelated)
-2.13.5 firmware
-direct CAN mapped on channels 1 & 2 from car, works fine
-ShiftX2 on CAN 2 using RJ45 splitter
-Disco Light Demo script works fine, starts immediately on RC hardware power up (no app) as intended
-Install allows RC & ShiftX2 to power up before CAN buses are alive
-Struggled with this "bug" - still no feedback viewtopic.php?t=6082
-Portion of script works fine, see below
Faults:
-Won't start on RC hardware power up, only starts after opening app and hitting Run, or flashing a new write
-Once started, RPM linear graph, and RHS Alert 0 (Oil Temp) works fine. LHS Alert 1 will not start or update.
--------This is true no matter what channel I pull into Alert 1, and Water temp updates no problem in the Dashboard
--------If I go to CAN mapping and open the CAN channel edit dialog box for Water and then hit the check mark to close out the window (no edits made), then and only then will Alert 1 turn on and receive a single value. Alert 1 value will never update again until I pretend to edit the CAN mapping again.
-ShiftX2 button press only randomly will report in the log, sometimes 0.0 or 1.0, far from consistent
Other Info:
-on Write reports 16Kb memory used, seems high for small script. What is included in that memory value?
-Flashing a new write will often cause the Wifi connection to be killed and reports back "Port Closed," typically takes multiple tries to achieve successful write
-Using the Poll feature often creates hangs and generates various error messages, kills connection, etc.
Code: Select all
--[[RPM Shift, Water & Oil Alerts]]
sxCan=1
sxId=0
tickRate=30
sxBright, sxScale=0,51 --[[0 auto 1-100, 51 default 0-255]]
function sxOnUpdate() --[[updates on tick]]
sxUpdateLinearGraph(getChannel("RPM"))
sxUpdateAlert(0,getChannel("OilTemp")) --[[rhs LED]]
sxUpdateAlert(1,getChannel("Water")) --[[lhs LED]]
end
function sxOnInit()
--[[L->R, smooth linear, min, max range]]
sxCfgLinearGraph(0,0,0,7300)
sxSetLinearThresh(0,0,2000,0 ,255,0 ,0) --[[green]]
sxSetLinearThresh(1,0,3500,255,255,0 ,0) --[[yellow]]
sxSetLinearThresh(2,0,6000,255,0 ,0 ,0) --[[red]]
sxSetLinearThresh(3,0,6500,255,255,255,10) --[[white flash]]
--[[config rhs LED, oil temp]]
sxSetAlertThresh(0,0,0 ,0 ,0 ,255,1) --[[blue flash]]
sxSetAlertThresh(0,1,180,0 ,255,0 ,0) --[[green]]
sxSetAlertThresh(0,2,210,255,255,0 ,0) --[[yellow]]
sxSetAlertThresh(0,3,225,255,0 ,0 ,0) --[[red]]
sxSetAlertThresh(0,4,240,255,0 ,0 ,10) --[[red flash]]
--[[config lhs LED, water temp]]
sxSetAlertThresh(1,0,0 ,0 ,0 ,255,1) --[[blue flash]]
sxSetAlertThresh(1,1,160,0 ,255,0 ,0) --[[green]]
sxSetAlertThresh(1,2,200,255,255,0 ,0) --[[yellow]]
sxSetAlertThresh(1,3,210,255,0 ,0 ,0) --[[red]]
sxSetAlertThresh(1,4,220,255,0 ,0 ,10) --[[red flash]]
end
function sxOnBut(b) --[[button state change]]
println('button: ' ..b)
end
--[[ShiftX2 functions]]
function sxSetLed(i,l,r,g,b,f)
sxTx(10,{i,l,r,g,b,f})
end
function sxSetLinearThresh(id,s,th,r,g,b,f)
sxTx(41,{id,s,spl(th),sph(th),r,g,b,f})
end
function sxSetAlertThresh(id,tid,th,r,g,b,f)
sxTx(21,{id,tid,spl(th),sph(th),r,g,b,f})
end
function setBaseConfig(bright,scale)
sxTx(3,{bright,scale})
end
function sxSetAlert(id,r,g,b,f)
sxTx(20,{id,r,g,b,f})
end
function sxUpdateAlert(id,v)
if v~=nil then sxTx(22,{id,spl(v),sph(v)}) end
end
function sxCfgLinearGraph(rs,ls,lr,hr)
sxTx(40,{rs,ls,spl(lr),sph(lr),spl(hr),sph(hr)})
end
function sxUpdateLinearGraph(v)
if v ~= nil then sxTx(42,{spl(v),sph(v)}) end
end
function sxInit()
println('config shiftX2')
setBaseConfig(sxBright,sxScale)
if sxOnInit~=nil then sxOnInit() end
end
function sxChkCan()
id,ext,data=rxCAN(sxCan,0)
if id==sxCanId then sxInit() end
if id==sxCanId+60 and sxOnBut~=nil then sxOnBut(data[1]) end
end
function sxProcess()
sxChkCan()
if sxOnUpdate~=nil then sxOnUpdate() end
end
function sxTx(offset, data)
txCAN(sxCan, sxCanId + offset, 1, data)
sleep(10)
end
function spl(v) return bit.band(v,0xFF) end
function sph(v) return bit.rshift(bit.band(v,0xFF00),8) end
function onTick()
sxProcess()
collectgarbage()
end
sxCanId = 0xE3600 + (256 * sxId)
println('shiftX2 base id '..sxCanId)
setTickRate(tickRate)
sxInit()