[Tinyos-commits] CVS: tinyos-1.x/apps/TestDripDrain DripDrainPing.h, NONE, 1.1 DripDrainPingC.nc, NONE, 1.1 DripDrainPingM.nc, NONE, 1.1 Makefile, NONE, 1.1 TestDripDrainC.nc, NONE, 1.1

Gilman Tolle gtolle at users.sourceforge.net
Thu Oct 27 14:32:05 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/apps/TestDripDrain
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15110

Added Files:
	DripDrainPing.h DripDrainPingC.nc DripDrainPingM.nc Makefile 
	TestDripDrainC.nc 
Log Message:
Test application for Drip and Drain - it's ping.

--- NEW FILE: DripDrainPing.h ---
enum {
  AM_DRIPDRAINPINGMSG = 1,
};

typedef struct DripDrainPingMsg {
  uint16_t identifier;
  uint16_t seqno;
} DripDrainPingMsg;

--- NEW FILE: DripDrainPingC.nc ---
includes DripDrainPing;

configuration DripDrainPingC {
  provides interface StdControl;
}
implementation {
  components DrainC;
  components DripC;
  components DripStateC;
  components DripDrainPingM;
  components LedsC;

  StdControl = DrainC;
  StdControl = DripC;
  StdControl = DripDrainPingM;
  
  DripDrainPingM.Send -> DrainC.Send[AM_DRIPDRAINPINGMSG];
  DripDrainPingM.SendMsg -> DrainC.SendMsg[AM_DRIPDRAINPINGMSG];
  
  DripDrainPingM.Receive -> DripC.Receive[AM_DRIPDRAINPINGMSG];
  DripDrainPingM.Drip -> DripC.Drip[AM_DRIPDRAINPINGMSG];
  DripC.DripState[AM_DRIPDRAINPINGMSG] -> DripStateC.DripState[unique("DripState")];  

  DripDrainPingM.Leds -> LedsC;
}

--- NEW FILE: DripDrainPingM.nc ---
includes DripDrainPing;

module DripDrainPingM {
  provides interface StdControl;
  uses interface Send;
  uses interface SendMsg;
  uses interface Receive;
  uses interface Drip;
  uses interface Leds;
}
implementation {

  TOS_Msg myBuf;
  DripDrainPingMsg dripCache;
  bool myBufBusy;
  
  task void sendReply();

  command result_t StdControl.init() {
    call Leds.redOn();
    call Drip.init();
    return SUCCESS;
  }

  command result_t StdControl.start() { return SUCCESS; }

  command result_t StdControl.stop() { return SUCCESS; }

  event TOS_MsgPtr Receive.receive(TOS_MsgPtr buf,
				   void* payload, uint16_t len) {

    DripDrainPingMsg* msg = (DripDrainPingMsg*) payload;
    memcpy(&dripCache, msg, sizeof(DripDrainPingMsg));

    post sendReply();
    return buf;
  }

  task void sendReply() {
    uint16_t length;
    DripDrainPingMsg* msg = call Send.getBuffer(&myBuf, &length);

    if (myBufBusy) {
      return;
    }

    call Leds.yellowToggle();

    myBufBusy = TRUE;
    memcpy(msg, &dripCache, sizeof(DripDrainPingMsg));
    call SendMsg.send(TOS_DEFAULT_ADDR,
		      sizeof(DripDrainPingMsg),
		      &myBuf);
  }

  event result_t Drip.rebroadcastRequest(TOS_MsgPtr buf, void* payload) {
    memcpy(payload, &dripCache, sizeof(DripDrainPingMsg));
    call Drip.rebroadcast(buf, payload, sizeof(DripDrainPingMsg));
    return SUCCESS;
  }

  event result_t Send.sendDone(TOS_MsgPtr buf, result_t result) { 
    return SUCCESS;
  }
  event result_t SendMsg.sendDone(TOS_MsgPtr buf, result_t result) { 
    myBufBusy = FALSE;
    return SUCCESS;
  }
}

--- NEW FILE: Makefile ---
COMPONENT=TestDripDrainC

PFLAGS += -I%T/lib/Drip
PFLAGS += -I%T/lib/Drain

include $(TOSDIR)/../apps/Makerules

--- NEW FILE: TestDripDrainC.nc ---
configuration TestDripDrainC { }
implementation {
  components Main;
  components DripDrainPingC;

  Main.StdControl -> DripDrainPingC;
}



More information about the Tinyos-commits mailing list