RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Can't "Run" my script
Author Message
Reply with quote
Post Can't "Run" my script 
I have a script that clearly is very close to the memory limit. It runs fine on power up. It also runs immediately after being written,
however if I try to restart it with the app's "Run" button lua fails to restart with the following messages:
Quote:
[lua] Successfully loaded script.
[lua] Gracefully stopping Lua Task
[lua] Destroying Lua State
[lua] Initializing Lua state
[lua] memory usage: 17KB
[lua] Starting Lua Task
[lua] Loading script. Length: 2205
timebase/logging/telemetry sample rate: 100/100/50
timebase/logging/telemetry sample rate: 100/100/50
[lua] Startup script error: (not enough memory)
[lua] Failure: Failed to load script




Last edited by lightningrod on Sun Jun 30, 2019 5:37 am; edited 1 time in total
View user's profile Send private message
Reply with quote
Post  
2.17.0 firmware will have a bit more memory freed up, so we should re-test this to find out if it makes a difference.

Can you post your memory consuming script here for testing?


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Reply with quote
Post  
The following script exhibits the symptoms under 2.16.0
Code:
r1=0
r2=0
function ah()
local r0=r1
r1=r2
r2=r1+(getChannel("RPM")/60-r0)/2
return r2
end
a1=0
a2=0
function ai()
local a0=a1
a1=a2
a2=a1+(-getImu(0)-a0)/2
return a2
end
function u()
ret=getChannel("WOT")
if ret~=nil then
return ret and 1 or 0
end
if getImu(0)<-0.01 then
local o=getImu(1)
if o*o<0.06 then return 1 end
end
return 0
end
e={}
O=0
H=0
V={}
function W(F,Z,a)
local A={}
A.ah=addChannel("dT_"..F,10,2,0,50,"ms/rpm")
A.F=F
A.U={}
A.r=Z
A.s=a
d(A)
e[O]=A
O=O+1
end
function aB(F,t,q,Z,a,p,G)
V[H]={}
V[H].G=G
V[H].F=F
for E=0,O-1 do
local A=e[E]
local C={}
C.G=addChannel(F..A.F,t,q,Z,a,p)
C.Q=0
C.T=0
A.U[H]=C
end
H=H+1
end
function d(A)
A.g=0
A.M=0
for E=0,H-1 do
A.U[E].Q=0
A.U[E].T=0
end
end
function an(A,b)
if b>=A.r then
if b<A.s then
if A.M==0 then
A.M=b
A.g=getUptime()
else
local n=b-A.M
if n>0 then
local ag=getUptime()-A.g
local ar=ag/n
setChannel(A.ah,ar)
end
end
for E=0,H-1 do
ao(A.U[E],V[E].G)
end
elseif A.M~=0 then
d(A)
end
end
end
function ao(C,ai)
local G=getChannel(ai)
if G then
C.T=C.T+1
C.Q=C.Q+G
local al=C.Q/C.T
setChannel(C.G,al)
end
end
function ap(X)
local b=getChannel("RPM")
for E=0,O-1 do
local A=e[E]
if X then
an(A,b)
else
if A.M~=0 then d(A)end
end
end
end
N=nil
R=nil
l=nil
function ay()
local J=bit.band
local I=readCSer(6,0)
while I do
D=D+1
if D==1 and J(I,0xA2)==0xA2 then
elseif D==2 and J(I,0x80)==0x80 then
elseif D==4 then
k=J(bit.rshift(R,2),7)
l=J(R,1)*0x80+
J(I,0x7F)
elseif D==6 then
local j=J(R,0x7F)*0x80+J(I,0x7F)
if k==0 then
N=(j+500)*l/10000
elseif k==1 then
N=j/10
end
D=0
elseif D~=3 and D~=5 then
D=0
end
R=I
I=readCSer(6,0)
end
if N then
setChannel(aA,N)
N=nil
end
end
function av()
local h=(getGpsSpeed()*0.44704)
local K=ah()
local aX=ai()
local w=(aX*9.8)*y+(ad+h*(ae+h*af))
local c=(w*h/(K*2*3.1416))
local f=((c/4.45)*(1*3.28084))
setChannel(ab,f)
setChannel(ac,(f*K*60/5252.0))
end
function onTick()
local X=u()==1
collectgarbage()
ay(X)
ap(X)
av()
sxUpdateLinearGraph(getChannel("RPM")/100)
end
initSer(6,19200,8,0,1)aA=addChannel("AFR",10,1,8,23)D=0
y=(2290*0.453592)af=0.5*0.335*1.72*1.22 ae=0.335 ad=6 ab=addChannel("Torque",10,1,0,150,"ft-lb")ac=addChannel("HP",10,1,0,150,"HP")
sxSetConfig(0,0,0)local m=sxSetLinearThresh sxCfgLinearGraph(0,0,0,75)m(0,0,5,0,0,127,0)m(1,0,39,0,127,0,0)m(2,0,68-8,127,255,0,0)m(3,0,68-4,255,127,0,0)m(4,0,68,255,0,0,10)
W("4",4000,5000)
W("5",5000,6000)
W("6",6000,7000)
aB("AF",10,1,7,25,"%O2",aA)
aB("Torque",10,0,50,150,"ft-lb",ab)
setTickRate(60)


View user's profile Send private message
Reply with quote
Post  
FWIW: this script still exhibits the same symptoms under 2.17.1.

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum