X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=apps%2Ftests%2Fstorage%2FLog%2FRandRWC.nc;h=7a79e132a96bf34803c8129c402826a85e630814;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=4e322de5217791521bc37fd21e6fbf14a32d37f2;hpb=1ba974b83d19fc41bf80acd52726f36f7f1df297;p=tinyos-2.x.git diff --git a/apps/tests/storage/Log/RandRWC.nc b/apps/tests/storage/Log/RandRWC.nc index 4e322de5..7a79e132 100644 --- a/apps/tests/storage/Log/RandRWC.nc +++ b/apps/tests/storage/Log/RandRWC.nc @@ -13,12 +13,6 @@ * * @author David Gay */ -/* - address & 3: - 1: erase, write - 2: read - 3: write some more -*/ module RandRWC { uses { interface Boot; @@ -68,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) { @@ -105,6 +103,8 @@ implementation { return b; } + volatile int x; + void setParameters() { len = rand() >> 8; offset = rand() >> 9; @@ -138,13 +138,23 @@ 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); + } } } - event void LogWrite.appendDone(void *buf, storage_len_t y, error_t result) { - if (scheck(result)) + event void LogWrite.appendDone(void *buf, storage_len_t y, bool recordsLost, error_t result) { + if (result == ESIZE) + scheck(call LogWrite.sync()); + else if (scheck(result)) nextWrite(); }