]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - apps/tests/storage/Log/RandRWC.nc
Shouldn't fail when you reach the end of the log. Sync instead.
[tinyos-2.x.git] / apps / tests / storage / Log / RandRWC.nc
index 7e5ae49ae099b3f4106a9c26c54e8d8be8c9fd13..7a79e132a96bf34803c8129c402826a85e630814 100644 (file)
@@ -62,14 +62,18 @@ implementation {
   int count, testCount;
   uint32_t len;
   uint16_t offset;
-  message_t reportmsg;
+  message_t reportMsg;
 
   void report(error_t e) {
-    uint8_t *msg = call AMSend.getPayload(&reportmsg);
+    uint8_t *msg = call AMSend.getPayload(&reportMsg, 1);
 
-    msg[0] = e;
-    if (call AMSend.send(AM_BROADCAST_ADDR, &reportmsg, 1) != SUCCESS)
-      call Leds.led0On();
+    if (msg)
+      {
+       msg[0] = e;
+       if (call AMSend.send(AM_BROADCAST_ADDR, &reportMsg, 1) == SUCCESS)
+         return;
+      }
+    call Leds.led0On();
   }
 
   event void AMSend.sendDone(message_t* msg, error_t error) {
@@ -134,8 +138,16 @@ implementation {
       scheck(call LogWrite.sync());
     else
       {
+       error_t result;
        setParameters();
-       scheck(call LogWrite.append(data + offset, len));
+       result = call LogWrite.append(data + offset, len);
+       if (result == ESIZE) {
+         // We have reached the end of the log, sync it
+         scheck(call LogWrite.sync());
+       }
+       else {
+         scheck(result);
+       }
       }
   }