[Tinyos-2-commits]
CVS: tinyos-2.x/apps/tests/eyesIFX/RadioCountToFlash
Makefile, NONE, 1.1.2.1 RadioCountToFlashAppC.nc, NONE,
1.1.2.1 RadioCountToFlashC.nc, NONE,
1.1.2.1 RadioCountToFlash.h, NONE, 1.1.2.1 README.txt, NONE,
1.1.2.1 volumes-at45db.xml, NONE, 1.1.2.1
Philipp Huppertz
phihup at users.sourceforge.net
Tue Sep 12 04:57:15 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/eyesIFX/RadioCountToFlash
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3513/apps/tests/eyesIFX/RadioCountToFlash
Added Files:
Tag: tinyos-2_0_devel-BRANCH
Makefile RadioCountToFlashAppC.nc RadioCountToFlashC.nc
RadioCountToFlash.h README.txt volumes-at45db.xml
Log Message:
- added test app for simultaneous radio and flash usage
--- NEW FILE: Makefile ---
COMPONENT=RadioCountToFlashAppC
BUILD_EXTRA_DEPS = RadioCountMsg.py RadioCountMsg.class
RadioCountMsg.py: RadioCountToFlash.h
mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioCountMsg RadioCountToFlash.h RadioCountMsg -o $@
RadioCountMsg.class: RadioCountMsg.java
javac RadioCountMsg.java
RadioCountMsg.java: RadioCountToFlash.h
mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RadioCountMsg RadioCountToFlash.h RadioCountMsg -o $@
include $(MAKERULES)
--- NEW FILE: RadioCountToFlashAppC.nc ---
/*
* "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2005 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* This application tests the coexistence of radio and flash.
* (based on RadioCountToLeds)
*
* @see README.TXT
* @author Philipp Huppertz
* @author Philip Levis (RadioCountToLeds)
* @date June 6 2005
*/
#include "RadioCountToFlash.h"
#include "StorageVolumes.h"
configuration RadioCountToFlashAppC {}
implementation {
components MainC, RadioCountToFlashC as App, LedsC, PlatformLedsC;
components new AMSenderC(AM_RADIOCOUNTMSG);
components new AMReceiverC(AM_RADIOCOUNTMSG);
components new TimerMilliC() as RadioTimer;
components new TimerMilliC() as FlashTimer;
components ActiveMessageC;
components new LogStorageC(VOLUME_LOGTEST, TRUE);
App.Boot -> MainC.Boot;
App.Receive -> AMReceiverC;
App.AMSend -> AMSenderC;
App.AMControl -> ActiveMessageC;
App.Leds -> LedsC;
App.FailureLed -> PlatformLedsC.Led3;
App.FlashTimer -> FlashTimer;
App.RadioTimer -> RadioTimer;
App.Packet -> AMSenderC;
App.LogRead -> LogStorageC.LogRead;
App.LogWrite -> LogStorageC.LogWrite;
}
--- NEW FILE: RadioCountToFlashC.nc ---
/*
* "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* This application tests the coexistence of radio and flash.
* (based on RadioCountToLeds)
*
* @see README.TXT
* @author Philipp Huppertz
* @author Philip Levis (RadioCountToLeds)
* @date June 6 2005
*/
#include "Timer.h"
#include "RadioCountToFlash.h"
#define LOG_LENGTH 15
module RadioCountToFlashC {
uses {
interface Leds;
interface Boot;
interface Receive;
interface AMSend;
interface Timer<TMilli> as FlashTimer;
interface Timer<TMilli> as RadioTimer;
interface SplitControl as AMControl;
interface Packet;
interface LogRead;
interface LogWrite;
interface GeneralIO as FailureLed;
}
}
implementation {
message_t packet;
bool locked;
uint16_t sendingCounter = 0;
uint16_t receiveCounter = 0;
uint16_t readBuffer = 0;
uint16_t logCounter = 0;
void failure() {
call FailureLed.set();
for (;;) {
;
}
}
task void readingTask() {
if (call LogRead.read((void*) &readBuffer, sizeof(receiveCounter)) != SUCCESS) {
post readingTask();
}
}
task void writingTask() {
if (call LogWrite.append((void*)receiveCounter, sizeof(receiveCounter)) != SUCCESS) {
post writingTask();
}
}
event void Boot.booted() {
call LogRead.seek(SEEK_BEGINNING);
call AMControl.start();
}
event void AMControl.startDone(error_t err) {
if (err == SUCCESS) {
call RadioTimer.startPeriodic(1000);
}
else {
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err) {
// do nothing
}
event void FlashTimer.fired() {
if (call LogRead.read((void*) &readBuffer, sizeof(receiveCounter)) != SUCCESS) {
post readingTask();
}
}
event void RadioTimer.fired() {
dbg("RadioCountToLedsC", "RadioCountToLedsC: timer fired, counter is %hu.\n", counter);
if (locked) {
return;
}
else {
RadioCountMsg* rcm = (RadioCountMsg*)call Packet.getPayload(&packet, NULL);
if (call Packet.maxPayloadLength() < sizeof(RadioCountMsg)) {
return;
}
++sendingCounter;
rcm->counter = sendingCounter;
if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(RadioCountMsg)) == SUCCESS) {
dbg("RadioCountToLedsC", "RadioCountToLedsC: packet sent.\n", counter);
locked = TRUE;
}
}
}
event message_t* Receive.receive(message_t* bufPtr, void* payload, uint8_t len) {
dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
if (len != sizeof(RadioCountMsg)) {return bufPtr;}
else {
RadioCountMsg* rcm = (RadioCountMsg*)payload;
receiveCounter = rcm->counter;
if (call LogWrite.append((void*)&receiveCounter, sizeof(receiveCounter)) != SUCCESS) {
post writingTask();
}
}
return bufPtr;
}
event void AMSend.sendDone(message_t* bufPtr, error_t error) {
if (&packet == bufPtr) {
locked = FALSE;
}
}
event void LogRead.readDone(void* buf, storage_len_t len, error_t error) {
--logCounter;
if (error != SUCCESS) {
failure();
}
readBuffer = *(uint16_t*)buf;
if ( logCounter > 0 ) {
if (readBuffer & 0x1) {
call Leds.led0On();
}
else {
call Leds.led0Off();
}
if (readBuffer & 0x2) {
call Leds.led1On();
}
else {
call Leds.led1Off();
}
if (readBuffer & 0x4) {
call Leds.led2On();
}
else {
call Leds.led2Off();
}
call FlashTimer.startOneShot(100);
}
}
event void LogRead.seekDone(error_t error) {
if (error != SUCCESS) {
failure();
}
}
event void LogWrite.appendDone(void* buf, storage_len_t len, error_t error) {
++logCounter;
if (error != SUCCESS) {
failure();
}
if (logCounter > LOG_LENGTH) {
if (call LogWrite.sync() != SUCCESS) {
failure();
}
}
}
event void LogWrite.syncDone(error_t error) {
if (error != SUCCESS) {
failure();
}
call FlashTimer.startOneShot(100);
}
event void LogWrite.eraseDone(error_t error) {
if (error != SUCCESS) {
failure();
}
}
}
--- NEW FILE: RadioCountToFlash.h ---
#ifndef RADIO_COUNT_TO_FLASH_H
#define RADIO_COUNT_TO_FLASH_H
typedef nx_struct RadioCountMsg {
nx_uint16_t counter;
} RadioCountMsg;
enum {
AM_RADIOCOUNTMSG = 6,
};
#endif
--- NEW FILE: README.txt ---
README for RadioCountToFlash
Description:
RadioCountToLeds maintains a 1Hz counter and broadcsts its value repeatedly. A
RadioCountToLeds node that hears a counter writes the counter to the flash.
After LOG_LENGTH (default = 16) successful receiptions the previously stored counters
are read from the flash with a delay of 100ms between each read. The bottom three bits
are displayed on the LEDs. This application tests the coexistance between
the radio and the flash.
Tools:
RadioCountMsg.java is a Java class representing the message that
this application sends. RadioCountMsg.py is a Python class representing
the message that this application sends.
Known bugs/limitations:
None.
--- NEW FILE: volumes-at45db.xml ---
<volume_table>
<volume name="LOGTEST" size="262144"/>
</volume_table>
More information about the Tinyos-2-commits
mailing list