Imp software not updating/requires reinsertion

Hi,

I got an Imp from one your awesome reps at the last YC hardware hackathon (my sister got one too!).

At the hackathon, everything was fantastic.

However, at home, my imp, which I just configured and got showing up in the planner, has the nasty habit of never receiving software updates after the led light turns off.

If I use this fragment:
while (true) { imp.sleep(2.5); server.log("alive") }

I can verify the imp is connected to the server.

But when I change anything, say “alive” to “alive!”, nothing happens.

The serverlog stops printing. No “downloading” or anything messages.

I am very confused, as it seems the imp only updates when I remove/reinsert the sd slot, which is rather different from the experience I had a few days back programming my sister’s imp.

I’ve seen issues about the firmware – would this be analogous to such?

You shouldn’t be looping like that - the imp requires you to exit the VM in order for the TCP stack to have a chance; we give the user thread priority to ensure predictable code execution. Your code should do whatever task it needs to, then return (or fall off the end of the main program) - the OS will then call back into your code when necessary to execute event handlers or timers.

The correct way to write that code would be:

function alive() {
imp.wakeup(2.5, alive);
server.log(“alive”);
}

// Start the callback running
alive();

…you’ll then find you can update the code etc.

Testing.

I spotted this issue originally, however, with merely using
server.log("Print a line and do nothing")

It still fails to allow for an update with a silly server.log.

Using imp.wakeup(…) works fine though and is part of my main.

Yeah. Works great with imp.wakeup.

Nope. Nope. No…

It didn’t work at ALL.

Imp disables ability to update software after several minutes.

This is using the imp.wakeup function.

Using imp.wakeup merely delays the bug from a few seconds to several mins.

Looking at the log:
Monday, February 25, 2013 7:30:12 PM: Downloading new code
Monday, February 25, 2013 7:30:13 PM: alive

Monday, February 25, 2013 7:33:53 PM: alive
< User attempts to download new code >

And nothing. Nothing gets printed after that.

Update – 40 mins later.

This bug appears to be transient. It occurs within half of the tests I run.

Bleh. That’s enough fiddling for tonight.

Are you calling imp.configure()? It doesn’t look like it (that would appear in the log you pasted).

You need to do this when your code boots to tell the server you’re alive. If you don’t, you may have variable results…

Got ya. It looks like I get consistent results with the configure code.

Wow. I had no idea that one programming paradigm (suspending the routines) and a missing configure could make the software upload so variable.

Looks pretty good now.

Thanks!