PDA

View Full Version : reboot() problem


korda
10-09-2008, 05:48 PM
If the "reboot()" called within the script, the node behavior changes.
It does not execute your script anymore, only built-in functions, except the reboot() itself, ironically.
It appears as a node's code got stack inside its own reboot function and has no time to continue the user's script.
If you trying to use Portal or other means to reboot this stack node - all the same, no way to recover.
Only power by down/up.

kbanks
10-10-2008, 09:44 AM
I retested the reboot() function yesterday and this morning, and it works fine.

I invoked it remotely (from Portal).

I also invoked it from inside a script. I exercised reboot() from the timer hook, the button hook, and from a standalone function.

Based on symptoms described to me in emails, here are some issues you may be running into.

1) As documented on page 51 of the SNAP Reference Manual, reboot() requests a reboot, it does not do an immediate reboot.

The actual reboot will occur 100-200 milliseconds after the reboot() function was invoked. (In other words, the reboot() built-in function starts a countdown).

This was done to give the ACKNOWLEDGEMENT of the reboot() request time to make it out the Packet Serial interface. (I forget who we made this change for, but somebody once upon a time kept telling their nodes to reboot over and over again, because the node did not reply to the message before doing the actual reboot).

What may not be obvious is that since reboot() STARTS a countdown, if you KEEP CALLING reboot() you will essentially be RESTARTING the countdown.

So, make sure you only call reboot() once.

2) Since reboot() only requests the reboot, your script can execute beyond that line of code. For example:


def example():
reboot()
x = 1 # this line WILL get executed!


So be careful what you put in your script AFTER a reboot() call.

You may want to set some sort of "rebootInProgress" flag within your script, and have the script NOT TAKE ACTIONS when the flag is set.

korda
10-10-2008, 10:29 AM
Kevin, you are saying that reboot() takes about 200 msec to complete. What we have seen, the reboot does not recover at all. It appears that node gets stuck in this function, and script does not run. I wanted to make this clear.

Second, this does not make sense when you saying reboot calls reboot. What do you mean by this? We do not have access to reboot function code to place another line there... May be you mean something else, it is not clear.

kbanks
10-10-2008, 01:11 PM
Sorry for the typo ( I put in extra () characters, that have since been edited out of the post).

The reboot() function starts a "countdown until node reboot".

kbanks
10-10-2008, 01:18 PM
Are your nodes going to sleep AFTER they execute the reboot() command (which SCHEDULES a future reboot) but before the countdown elapses and the actual reboot occurs?

The scheduled reboot will not take place WHILE the nodes are asleep (because they are asleep, they cannot check the countdown)

korda
10-14-2008, 01:37 PM
Our script called "reboot()" after node was awakened and becomes active.
We could see node gets awake but never got a chance to reload script...