Hello,
Why are there all offsets set to zero?
it prints out:
read_offset1: 0
read_offset2: 0
write_offset1: 0
write_offset2: 0
Gerald
#include "Timer.h"
#include "TestSerial.h"
#include <printf.h>
module TestSerialC {
uses {
interface SplitControl as Control;
interface Leds;
interface Boot;
interface Receive;
interface AMSend;
interface Timer<TMilli> as MilliTimer;
interface Timer<TMilli> as InitTimer;
interface Packet;
interface LogRead;
interface LogWrite;
}
}
implementation {
message_t packet;
typedef nx_struct logentry_t {
nx_uint16_t counter;
} logentry_t;
bool m_busy = FALSE;
logentry_t m_entry;
bool locked = FALSE;
storage_cookie_t read_offset1;
storage_cookie_t read_offset2;
storage_cookie_t write_offset1;
storage_cookie_t write_offset2;
event void Boot.booted() {
call Control.start();
call InitTimer.startOneShot(1000);
}
event void InitTimer.fired() {
int16_t i = 0;
write_offset1 = call LogWrite.currentOffset();
read_offset1 = call LogRead.currentOffset();
// we want to read from the starting point of the first write
call LogRead.seek(call LogWrite.currentOffset());
read_offset2 = call LogRead.currentOffset();
// we write some data in the flash storage
for(i=0; i < 1000; i++) {
if (!m_busy) {
m_busy = TRUE;
m_entry.counter = i;
if (call LogWrite.append(&m_entry, sizeof(logentry_t)) != SUCCESS) {
m_busy = FALSE;
}
}
}
write_offset2 = call LogWrite.currentOffset();
call MilliTimer.startPeriodic(1000);
}
event void MilliTimer.fired() {
printf("read_offset1: %u\n", read_offset1);
printf("read_offset2: %u\n", read_offset2);
printf("write_offset1: %u\n", write_offset1);
printf("write_offset2: %u\n", write_offset2);
printfflush();
if (call LogRead.read(&m_entry, sizeof(logentry_t)) != SUCCESS) {
// Handle error.
}
}
event void LogWrite.appendDone(void* buf, storage_len_t len,
bool recordsLost, error_t err) {
m_busy = FALSE;
}
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help