[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/storage/SyncLog
Makefile, NONE, 1.1 README.txt, NONE, 1.1 SyncLogAppC.nc, NONE,
1.1 SyncLogC.nc, NONE, 1.1 volumes-at45db.xml, NONE,
1.1 volumes-pxa27xp30.xml, NONE, 1.1 volumes-stm25p.xml, NONE, 1.1
David Gay
idgay at users.sourceforge.net
Wed Jul 11 11:10:36 PDT 2007
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/storage/SyncLog
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20719
Added Files:
Makefile README.txt SyncLogAppC.nc SyncLogC.nc
volumes-at45db.xml volumes-pxa27xp30.xml volumes-stm25p.xml
Log Message:
Sync test for flash logs
--- NEW FILE: Makefile ---
COMPONENT=SyncLogAppC
include $(MAKERULES)
--- NEW FILE: README.txt ---
README for Log
Author/Contact: tinyos-help at millennium.berkeley.edu
Description:
Application to test 'sync' functionality in the LogStorageC
abstraction, using the log in linear mode. There must be a
volumes-<chip>.xml file in this directory describing a 64kB volume
named SYNCLOG for your flash chip.
A successful test will send serial messages (id 11) with increasing
sequence numbers (approximately 2 messages every 5 seconds) - the
easiest way to see these messages is to connect the mote with the
SyncLog code to your PC and run the java Listen tool:
MOTECOM=serial@<your mote details> java net.tinyos.tools.Listen
This test is based on code and a bug report from Mayur Maheshwari
(mayur.maheshwari at gmail.com).
Tools:
Known bugs/limitations:
None.
$Id: README.txt,v 1.1 2007/07/11 18:10:34 idgay Exp $
--- NEW FILE: SyncLogAppC.nc ---
/**
* Test reading and writing to a log with lots of syncs. See README.txt for
* more details.
*
* @author Mayur Maheshwari (mayur.maheshwari at gmail.com)
* @author David Gay
*/
#include "StorageVolumes.h"
configuration SyncLogAppC { }
implementation {
components SyncLogC,
new TimerMilliC() as Timer0, new TimerMilliC() as Timer1,
new LogStorageC(VOLUME_SYNCLOG, FALSE), SerialActiveMessageC,
MainC, LedsC;
SyncLogC.Leds -> LedsC;
SyncLogC.Boot -> MainC;
SyncLogC.Timer0 -> Timer0;
SyncLogC.Timer1 -> Timer1;
SyncLogC.LogWrite -> LogStorageC;
SyncLogC.LogRead -> LogStorageC;
SyncLogC.AMSend -> SerialActiveMessageC.AMSend[11];
SyncLogC.AMControl -> SerialActiveMessageC;
}
--- NEW FILE: SyncLogC.nc ---
/**
* Test reading and writing to a log with lots of syncs. See README.txt for
* more details.
*
* @author Mayur Maheshwari (mayur.maheshwari at gmail.com)
* @author David Gay
*/
module SyncLogC
{
uses {
interface Leds;
interface Boot;
interface SplitControl as AMControl;
interface LogWrite;
interface LogRead;
interface Timer<TMilli> as Timer0;
interface Timer<TMilli> as Timer1;
interface AMSend;
}
}
implementation {
uint16_t data = 0;
uint16_t readings = 0;
message_t pkt;
bool busy = FALSE;
bool logBusy = FALSE;
task void sendTask();
storage_cookie_t readCookie;
storage_cookie_t writeCookie;
#define SAMPLING_FREQUENCY 2333
#define TIMER_PERIOD_MILLI 5120
event void Boot.booted() {
call AMControl.start();
}
event void AMControl.startDone(error_t err) {
if (err == SUCCESS)
call LogWrite.erase();
else
call AMControl.start();
}
event void LogWrite.eraseDone(error_t result) {
call Timer1.startPeriodic(SAMPLING_FREQUENCY);
call Timer0.startPeriodic(TIMER_PERIOD_MILLI);
}
event void Timer1.fired()
{
readings++;
if (!logBusy)
{
logBusy = TRUE;
call LogWrite.append(&readings, sizeof(readings));
}
}
event void LogWrite.appendDone(void *buf, storage_len_t len, bool recordsLost, error_t result) {
if (result == SUCCESS)
call LogWrite.sync();
}
event void LogWrite.syncDone(error_t result) {
logBusy = FALSE;
call Leds.led2Toggle();
}
event void Timer0.fired() {
call Timer1.stop();
if (!logBusy)
{
call Leds.led0Toggle();
logBusy = TRUE;
call LogRead.read(&data, sizeof data);
}
}
event void LogRead.readDone(void* buf, storage_len_t len, error_t error) {
if (error == SUCCESS)
if (len == sizeof data)
post sendTask();
else
{
logBusy = FALSE;
call Timer1.startPeriodic(SAMPLING_FREQUENCY);
}
}
typedef nx_struct {
nx_uint16_t nodeid;
nx_uint16_t payloadData;
} SenseStoreRadioMsg;
task void sendTask() {
if (!busy)
{
SenseStoreRadioMsg* ssrpkt =
(SenseStoreRadioMsg*)(call AMSend.getPayload(&pkt));
ssrpkt->nodeid = TOS_NODE_ID;
ssrpkt->payloadData = data;
if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(SenseStoreRadioMsg)) == SUCCESS)
busy = TRUE;
}
}
event void AMSend.sendDone(message_t* msg, error_t err) {
if (&pkt == msg)
{
busy = FALSE;
call LogRead.read(&data, sizeof data);
}
}
event void LogRead.seekDone(error_t error) { }
event void AMControl.stopDone(error_t err) { }
}
--- NEW FILE: volumes-at45db.xml ---
<volume_table>
<volume name="SYNCLOG" size="65536"/>
</volume_table>
--- NEW FILE: volumes-pxa27xp30.xml ---
<volume_table>
<volume name="SYNCLOG" size="65536"/>
</volume_table>
--- NEW FILE: volumes-stm25p.xml ---
<volume_table>
<volume name="SYNCLOG" size="65536"/>
</volume_table>
More information about the Tinyos-2-commits
mailing list