Server.show() does not update

Sometimes it does not update the screen in planner. I mean never. It only works when I click on the background or the blue box immediately. Other times it works perfectly with the same code. See below:

Am I doing something wrong in my code? I cannot see the pattern why sometimes it works other times not.

`local i=0,j,k;

function myloop(){
for(k=j=0;j<10;j++){k+=imp.rssi();imp.sleep(0.6);}
server.show(i+(k+950)/5);
imp.wakeup(4,myloop);
}

imp.configure(“RSSI”,[],[]);
myloop();
`

This code never updates unless I click the background or blue box when it’s blinking green.

imp.configure("RSSI",[],[]); if (("nv" in getroottable()) && ("count" in nv)) { server.show(format("%d %d",time()-nv.count,(imp.rssi()+95)/5)); imp.sleep(4); nv.count=time(); } else nv <- {count = time()}; server.sleepfor(30);

The first code snippet should work, the issue sounds like it could be browser side. Which browser?

The second one is not good because you shouldn’t be calling server.sleepfor() from root level - there would have been a logged warning about that.

imp.onidle(function(){server.sleepfor(30);});
…would be the correct way. Also, imp.sleep’s are not a good thing to be using here. If you wanted to stay awake for 4 seconds then sleep, try this:

imp.wakeup(4, function(){server.sleepfor(30)});

Firefox 19.0.2 will try imp.onidle

Works much better after following your suggestions above. But it still takes 30+ secs to go Green after Sleep.

`//Comment
local i=0,j,k;

function myloop(){
for(k=j=0;j<10;j++){k+=imp.rssi();imp.sleep(0.6);}
//k/=10;
server.show(i+(k+950)/5);
//i+=1000;
imp.wakeup(4,myloop); //does not update when at top
}

imp.configure(“RSSI”,[],[]);
//myloop();

//only updates screen sometimes no idea why
if ((“nv” in getroottable()) && (“count” in nv)) {
server.show(format("%d %d",time()-nv.count,(imp.rssi()+95)/5));
nv.count=time();
}
else nv <- {count = time()};
imp.wakeup(4, function(){server.sleepfor(30)});
//imp.onidle(function(){server.sleepfor(30);});
`

Now it’s connecting in 5 sec. But the planner is not updating. Sometimes it works, sometimes it doesn’t. Browser issue? Unpredictable!

Google Chrome seems to work better? But how do I know for sure? Sometimes it worked with Firefox.

Chrome is what we use mostly; the planner is currently a bit of a mess of HTML5 canvas, which has variable quality support even release to release on some browsers.

Moral of the story is use server.log() if you want to log something.

Excellent advice