Try erase the volume first.
Mike
On Feb 24, 2009, at 12:13 PM, Parkurm wrote:
> Hi, I think I'm experiencing problem in LogWrite. When I try
> LogWrite.append, when it signals appendDone, the error_t result is
> always FAIL. Can anybody point out the possible reasons for a
> failure in appendDone event?
>
> Here is my source code. When I run it (with the mote connected to
> the programming board), I get printout like the following:
> "Sensed data 31,writing to log..not busy, so we can write..appending
> log..append failed, buf is original, len=0,err=FAIL"
>
>
> #include "Log.h"
> #include "printf.h"
> module MyLogWriteP {
> uses {
> interface Boot;
> interface Leds;
> interface LogWrite;
> interface Timer<TMilli>;
> interface Read<uint16_t>;
> }
> }
> implementation {
>
> enum {
> SENSE_INTERVAL = 2000
> };
> typedef nx_struct logentry_t {
> nx_uint16_t data;
> } logentry_t;
>
>
> bool m_busy = FALSE;
> logentry_t m_entry;
>
> event void Boot.booted() {
> call Timer.startPeriodic(SENSE_INTERVAL);
> }
>
>
>
> event void Timer.fired() {
> call Leds.led0On();//start sensing
> call Read.read();
> }
> event void Read.readDone(error_t result,uint16_t data) {
> call Leds.led0Off();//end sensing
> if (result==SUCCESS) {
> printf("Sensed data %d,writing to log..",data);
> m_entry.data=data;
> if (!m_busy) {
> m_busy=TRUE;
> printf("not busy, so we can write..");
> call Leds.led1On();//start logging
> if (call LogWrite.append(&m_entry,sizeof(m_entry))!=SUCCESS) {
> m_busy=FALSE;
> printf("Failed to initiate append log\n");
> call Leds.led1Off();//log failure
> }
> else {
> printf("appending log..");
> }
> }
> else {
> printf("busy, so this data is abandoned\n");
> }
> }
> }
>
> event void LogWrite.eraseDone(error_t err) {
> printf("Errase Done\n");
> }
> event void LogWrite.appendDone(void* buf, storage_len_t len,
> bool recordsLost, error_t err) {
> if (err==SUCCESS) {
> printf("append success!\n");
> call Leds.led2Toggle();
> }
> else {
>
> printf("append failed, ");
> printf("buf %s original, ",buf==&m_entry?"is":"is not");
> printf("len=%d,",len);
> if(err==ESIZE)
> printf("err=ESIZE\n");
> if(err==FAIL)
> printf("err=FAIL\n");
> else
> printf("err unknown\n");
> }
> call Leds.led1Off();
> m_busy=FALSE;
> }
>
> event void LogWrite.syncDone(error_t err) {
> printf("Does anything happen here?\n");
> }
>
> }
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help