Hi all!

I need to log in EEPROM the data adquisition of every sensor (14 bytes) and
a time stamp to indicate the time of the adquisition (8 bytes). So, i need
to store in EEPROM 22 bytes. The size of the EEPROM for mica2 is 16 bytes.
How can i store data with component Logger?

I have tried to do this with this code:
------------------------
...

typedef struct LogMsg{
  uint64_t time;
  uint16_t temperature;
  uint16_t humidity;
  uint16_t pressure;
  uint16_t photoA;
  uint16_t photoB;
  uint16_t accelX;
  uint16_t accelY;
} LogMsg_t;

...

uint8_t c_write;
uint8_t c_read;
LogMsg_t msg;

void writeMsg(){


  char *ptr = (char *)msg;
  atomic{
    msg.time = 0x0000000000000000;
    msg.temperature  = 0xAAAA;
    msg.humidity = 0xBBBB;
    msg.pressure = 0xCCCC;
    msg.photoA = 0xDDDD;
    msg.photoC = 0xEEEE;
    msg.accelX = 0xFFFF;
    msg.accelY = 0x1234;
  }
  c_write = 0;
  LoggerWrite.append(ptr);
}

result_t LoggerWrite.writeDone(result_t success){

  char *ptr;

  if(c_write == 0){
    c_write = 1;
    ptr = (char *)msg + TOS_EEPROM_LINE_SIZE;
    LoggerWrite.append(ptr);
  }

  return SUCCESS;
}

void readMsg(){
  char *ptr = (char *)msg;
  c_read = 0;
  LoggerRead.readNext(ptr);
}


result_t LoggerRead.readDone(result_t success){
  char *ptr;
  if(c_read == 0){
    ptr = (char *)msg + TOS_EEPROM_LINE_SIZE;
    c_read = 1;
    LoggerRead.readNext(ptr);
  }else if(c_read == 1){
    // Send message through UART
    ...
  }

  return SUCCESS;
}
------------------------

When i listen the serial port on my PC, the message is only correct on the
first 16 bytes of data (time, temperature, humidity, pressure and photoA).
What's wrong in the code??

Thanks!!!!!
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to