NV Table Unexpected Recycle and Crash

I have the imp running as a datalogger posting values to the server every minute, every day. I’ve been running into hang up issues where the imp stops sending data unless I physically restart the april board.

I’ve replicated this with a simple hello world. The imp prints “hello world” with a count of how many times it’s gone through the cycle. It continues to either restart the count or stop reporting completely after 497 cycles. I’ve found the same result at log times of every 3 seconds and every 1 second.

Mon May 27 2013 11:36:36 GMT-0400 (EDT): Device configured to be "Hello World Program"
Mon May 27 2013 11:36:36 GMT-0400 (EDT): Hello World 497
Mon May 27 2013 11:36:36 GMT-0400 (EDT): Running at 3.27 V
Mon May 27 2013 11:36:36 GMT-0400 (EDT): sleeping until 1369669001000
Mon May 27 2013 11:36:36 GMT-0400 (EDT): Power state: online=>asleep
Mon May 27 2013 11:36:56 GMT-0400 (EDT): Power state: asleep=>online
Mon May 27 2013 11:36:57 GMT-0400 (EDT): Device booting
Mon May 27 2013 11:36:57 GMT-0400 (EDT): Device configured to be "Hello World Program"
Mon May 27 2013 11:36:57 GMT-0400 (EDT): Hello World 0
Mon May 27 2013 11:36:57 GMT-0400 (EDT): Running at 3.27 V
Mon May 27 2013 11:36:57 GMT-0400 (EDT): sleeping until 1369669022000
Mon May 27 2013 11:36:57 GMT-0400 (EDT): Power state: online=>asleep

`
// Hello World Example

// Initialize NV Table or Advance Count
if ((“nv” in getroottable()) && (“count” in nv)) {
nv.count++;
} else {
nv <- {id = imp.getmacaddress(), voltage=-1, count = 0, datetime = time(), datapoints = [0,0]};
}

// Initialize Hardware Pins to ADC
adc_1 <- hardware.pin2.configure(ANALOG_IN);
adc_2 <- hardware.pin8.configure(ANALOG_IN);

// Initialize Imp Output
data_output <- OutputPort(“data”);

// Initialize Sample Variables
reading <- 0;
num_reads <- 5;
num_samples <- 10;
log_interval <- 1;

function hello_world(){
server.log("Hello World " + nv.count);
check_battery();
}

function check_battery(){
local battery_voltage = 0;
for(local i = 0; i < 10; i++){
imp.sleep(0.01);
battery_voltage += hardware.voltage();
}
battery_voltage = battery_voltage / 10.0;
server.log(format(“Running at %.2f V”, battery_voltage));
nv.voltage = format("%.2f", battery_voltage);
}

// Register with Server
imp.configure(“Hello World Program”, [], []);
hello_world();
imp.onidle(function(){server.sleepfor(log_interval);});

// End Of Code`

I tried this, but I can’t reproduce it with your code, at least on the forthcoming release. Are you sure you aren’t running out of space in the nv table in your logging code?

Peter

That was my thought, but I don’t have anything else in the NV table except this count. You were able to count past 497?

Yes, 560 or so before I got bored :wink:

Peter