Infinite reset loop

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="http://autosportlabs.net/RaceCapturePro_Lua_Scripting">Lua Scripting Guide</a>

Moderators: JeffC, stieg

zechdz
Posts: 44
Joined: Sun Nov 08, 2015 3:04 pm

Infinite reset loop

Post by zechdz »

I made a small mistake in my lua script and it seems like my RCP is stuck in an infinite reset loop.
Tried downgrading and upgrading the firmware but that did nothing.

I also probably lost my config without saving so thats depressing.

How can you get out of an infinite reset loop?

added info: Watching the uptime in the app it resets every 4 seconds.
Last edited by zechdz on Tue Feb 09, 2016 3:55 pm, edited 1 time in total.
vroom

zechdz
Posts: 44
Joined: Sun Nov 08, 2015 3:04 pm

Post by zechdz »

I tried the bootloader method as well

https://www.autosportlabs.net/RaceCaptu ... e_Firmware
vroom

zechdz
Posts: 44
Joined: Sun Nov 08, 2015 3:04 pm

Post by zechdz »

I now sometimes get this when I try to connect. Even though when I do successfully connect the top bar says 2.8.7
Attachments
unspecified-4.png
unspecified-4.png (33.41 KiB) Viewed 12292 times
Last edited by zechdz on Tue Feb 09, 2016 3:47 pm, edited 1 time in total.
vroom

zechdz
Posts: 44
Joined: Sun Nov 08, 2015 3:04 pm

Post by zechdz »

This too
Attachments
unspecified-5.png
unspecified-5.png (24.16 KiB) Viewed 12291 times
vroom

gizmodo
Posts: 138
Joined: Mon Aug 05, 2013 10:22 pm

Post by gizmodo »

You could try connecting to the RCP with HyperTerminal. After that, see if issuing the "resetConfig" command works.

zechdz
Posts: 44
Joined: Sun Nov 08, 2015 3:04 pm

Post by zechdz »

It was continuously resetting so when I tried the command below it wouldn't connect far enough for me to issue the resetConfig command, just like the app because the RCP wouldnt stay on for more than 4 seconds.

The docs also say that when updating firmware, when you put into bootloader mode the app will not connect but firmware can be updated. In the same way, in bootloader mode I could not use the below command to connect.
screen /dev/tty.rcpport
Eventually I just overwrote the firmward back and forth many times and tried to write a blank lua script many times, and it eventually worked.

My issue was using

> "else if" like in java instead of "elseif" like in lua
vroom

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Ouch, sorry about that. We're looking at ensuring the script is writable in case you get it into an infinite loop.

The factory reset option is one way to go, via command line. We're also going to make it available via the UI as well.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

stieg
Posts: 100
Joined: Fri Dec 20, 2013 1:37 am
Location: Madison, WI
Contact:

Post by stieg »

zechdz,

When the unit first powers on, there is a 5 second window to disable the LUA run time by clicking the front button. Try that and see if it gets you back in the game.

That is also pretty bad if the LUA run time is able to crash the RCP unit. Once you get out of the loop, will you kindly post the code that you believe is causing the issue so we can fix it. Thanks.
Andrew Stiegmann (Stieg)
Principal Engineer
Autosport Labs Inc.

zechdz
Posts: 44
Joined: Sun Nov 08, 2015 3:04 pm

Post by zechdz »

I wrote a post above. I somehow got it to work by resetting the firmware a bunch of times... maybe i pushed that button one of those times :-D

Next time i'll keep that in mind and use the button.

Also the problem was just a syntax error.

else if instead of elseif
vroom

Mash
Posts: 19
Joined: Sun Dec 27, 2015 7:23 am

Post by Mash »

Now Im in situation that nothing allows me to update script:
- Flash firmware through bootloader (flashes, script stays)
- resetConfig through terminal stucks after Flashing Default Logger Config PASS
- press button shortly within 5 seconds after load - doesn't stop script from loading
- writing script through the App - timeout waiting for setScriptCfg
- Reload of config says "Port Closed"

Spent few hours already.
It shows me that old script sometime and then it goes to disconnect-connect cycle so I can't read log or update script.
It shows me detected v0.0.0 and so on once I'm trying to read a log.

Mash
Posts: 19
Joined: Sun Dec 27, 2015 7:23 am

Post by Mash »

Rolled back to 2.8.7 through bootloader - that helped. After that resetConfig worked fine.

Mash
Posts: 19
Joined: Sun Dec 27, 2015 7:23 am

Post by Mash »

Now tried to put same script and same story again. This is the script:

Code: Select all

local a=3;local b=43.5;local c=addChannel&#40;"CAN",1,0,0,300,"Hz"&#41;initCAN&#40;0,500000&#41;setTickRate&#40;1000&#41;local d=true;function onTick&#40;&#41;if d then d=false;for e=1,10 do rxCAN&#40;0,5&#41;end;readCANmap&#40;&#41;end;if d then local f=getUptime&#40;&#41;local g=0;repeat collectgarbage&#40;&#41;g=g+1 until getUptime&#40;&#41;>f+1000;setChannel&#40;c,g&#41;end end;local h=&#123;&#125;local i="0123456789ABCDEF"function readCANmap&#40;&#41;local j=1;while j<=string.len&#40;i&#41;do local k=0;while k~=44 and k~=59 and k~=64 do println&#40;k&#41;j=j+1;k=string.byte&#40;i,j&#41;end end end;function readCAN&#40;l,m&#41;for e,n in ipairs&#40;l&#41;do local o=n&#91;3&#93;local p=n&#91;4&#93;if p==nil then p=o;o=1 end;if m%o==0 then local q=n&#91;5&#93;if q==nil then q=0;for r,s in ipairs&#40;p&#41;do q=q+s&#91;1&#93;end;q=q/8;n&#91;5&#93;=q end;local t=readCANdata&#40;n&#91;1&#93;,n&#91;2&#93;,q&#41;if t~=nil then local u=1;for e,s in ipairs&#40;p&#41;do local v=setChannelData&#40;s,t,u&#41;u=u+v end end end end end;function setChannelData&#40;s,t,u&#41;if s&#91;2&#93;==nil and s&#91;9&#93;==nil then return s&#91;1&#93;end;if s&#91;9&#93;==nil then if s&#91;5&#93;==nil then s&#91;5&#93;=""end;if s&#91;6&#93;==nil then s&#91;6&#93;=1 end;if s&#91;7&#93;==nil then s&#91;7&#93;=0 end;if s&#91;8&#93;==nil then s&#91;8&#93;=false end;local w=0;if s&#91;6&#93;<0.001 then w=4 elseif s&#91;6&#93;<0.01 then w=3 elseif s&#91;6&#93;<0.1 then w=2 elseif s&#91;6&#93;<1 then w=1 end;s&#91;9&#93;=addChannel&#40;s&#91;2&#93;,1000,w,s&#91;3&#93;,s&#91;4&#93;,s&#91;5&#93;&#41;s&#91;2&#93;=nil;s&#91;3&#93;=nil;s&#91;4&#93;=nil;s&#91;5&#93;=nil end;setChannel&#40;s&#91;9&#93;,getBitsNumber&#40;t,u,s&#91;1&#93;,s&#91;8&#93;&#41;*s&#91;6&#93;+s&#91;7&#93;&#41;return s&#91;1&#93;end;local x=&#123;0x1,0x3,0x7,0xF,0x1F,0x3F,0x7F,0xFF,0x1FF,0x3FF,0x7FF,0xFFF,0x1FFF,0x3FFF,0x7FFF,0xFFFF,0x1FFFF,0x3FFFF,0x7FFFF,0xFFFFF,0x1FFFFF,0x3FFFFF,0x7FFFFF,0xFFFFFF&#125;local y,z,A=bit.band,bit.bxor,bit.bnot;local B,C=bit.lshift,bit.rshift;function getBitsNumber&#40;D,E,F,G&#41;local H=&#40;8-&#40;E+F-1&#41;%8&#41;%8;local I=1+&#40;E-1-&#40;E-1&#41;%8&#41;/8;local J=D&#91;I&#93;if F+H>8 then J=D&#91;I+1&#93;+B&#40;J,8&#41;if F+H>16 then J=D&#91;I+2&#93;+B&#40;J,8&#41;end end;J=C&#40;J,H&#41;J=y&#40;J,x&#91;F&#93;&#41;if G then J=unsign16Bits&#40;J&#41;end;return J end;function unsign16Bits&#40;K&#41;if K>0x7FFF then local L=C&#40;K,8&#41;local M=y&#40;K,0xFF&#41;local N=0-B&#40;y&#40;-A&#40;0x1000+L&#41;,0x00FF&#41;,8&#41;N=N-y&#40;-z&#40;0x1000+M,0x0000&#41;,0x00FF&#41;-1;return N end;return K end;function readCANdata&#40;O,P,q&#41;local Q=&#123;2,0x21,255,255,255,255,255,255&#125;local R=&#123;48,8,0,255,255,255,255,255&#125;local S=100;local T=P>255;if T then Q&#91;1&#93;=5;Q&#91;2&#93;=0x23;Q&#91;3&#93;=C&#40;P,16&#41;Q&#91;4&#93;=y&#40;C&#40;P,8&#41;,x&#91;8&#93;&#41;Q&#91;5&#93;=y&#40;P,x&#91;8&#93;&#41;Q&#91;6&#93;=q else Q&#91;3&#93;=P end;res=txCAN&#40;0,O,0,Q,S&#41;if res~=1 then return nil end;local t=&#123;&#125;local U,V,W=rxCAN&#40;0,S&#41;if U==nil then return nil end;local X=W&#91;1&#93;==0x10;local e=1;local Y=3;if X then Y=Y+1 end;if not T then Y=Y+1 end;while Y<9 do t&#91;e&#93;=W&#91;Y&#93;e=e+1;Y=Y+1 end;if not X then return t end;res=txCAN&#40;0,O,0,R,S&#41;if res~=1 then return nil end;local Z=&#40;W&#91;2&#93;+1&#41;/7;for _=1,Z do local U,V,W=rxCAN&#40;0,S&#41;if U==nil then return nil end;local Y=2;while Y<9 and e<q+1 do t&#91;e&#93;=W&#91;Y&#93;e=e+1;Y=Y+1 end end;return t end

Mash
Posts: 19
Joined: Sun Dec 27, 2015 7:23 am

Post by Mash »

Applying same script and it refuses to run it without explanation. On 2.9.0 RC4 it hangs system

stieg
Posts: 100
Joined: Fri Dec 20, 2013 1:37 am
Location: Madison, WI
Contact:

Post by stieg »

That is no good. Will have a look and get back to ya.
Andrew Stiegmann (Stieg)
Principal Engineer
Autosport Labs Inc.

stieg
Posts: 100
Joined: Fri Dec 20, 2013 1:37 am
Location: Madison, WI
Contact:

Post by stieg »

As per email discussion and to resolve this here, this is fixed in 2.9.0 and will be part of that release.
Andrew Stiegmann (Stieg)
Principal Engineer
Autosport Labs Inc.

Post Reply