[Tinyos-beta-commits]
CVS: tinyos-1.x/beta/Drip/tools/java/net/tinyos/drip
Drip.java, 1.2, 1.3
Gilman Tolle
gtolle at users.sourceforge.net
Tue Apr 26 19:48:28 PDT 2005
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip Drip.h, 1.1,
1.2 DripC.nc, 1.2, 1.3 DripM.nc, 1.2, 1.3 DripStateM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip WakeupComm.h, NONE,
1.1 WakeupCommC.nc, NONE, 1.1 WakeupCommM.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/beta/Drip/tools/java/net/tinyos/drip
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14669/tools/java/net/tinyos/drip
Modified Files:
Drip.java
Log Message:
Added support for a wakeup bit in the Drip message. The last bit of the sequence number is the wakeup bit. When the bit is set, the message is rebroadcast multiple times, to wake up a sleeping node. This technique allows any Drip message to wake up a sleeping network.
Index: Drip.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drip/tools/java/net/tinyos/drip/Drip.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Drip.java 14 Apr 2005 23:47:58 -0000 1.2
--- Drip.java 27 Apr 2005 02:48:26 -0000 1.3
***************
*** 45,48 ****
--- 45,50 ----
boolean sentOK = true;
+ boolean wakeupMsg = false;
+
public Drip(int id) {
***************
*** 65,68 ****
--- 67,71 ----
sendCount = 0;
state = PROBING;
+ wakeupMsg = false;
seqno = DripConsts.DRIP_SEQNO_OLDEST;
maxSendCount = SEND_COUNT;
***************
*** 83,86 ****
--- 86,90 ----
state = SENDING_NEW;
seqno = DripConsts.DRIP_SEQNO_NEWEST;
+ wakeupMsg = true;
maxSendCount = WAKEUP_SEND_COUNT;
trickle.schedule(this, 0, WAKEUP_SEND_RATE);
***************
*** 125,128 ****
--- 129,136 ----
}
+ if (wakeupMsg == true) {
+ dripMsg.set_metadata_seqno((short)((dripMsg.get_metadata_seqno()+1) % 256));
+ }
+
if (DEBUG) {
System.out.println("Sending Msg: id=" + id + ",seqno=" + seqno);
***************
*** 176,195 ****
private void incrementSeqno() {
seqno = (seqno + 1) % 256;
! while (seqno == DripConsts.DRIP_SEQNO_OLDEST ||
! seqno == DripConsts.DRIP_SEQNO_NEWEST) {
seqno = (seqno + 1) % 256;
}
}
!
public static void main(String[] args) {
- String data = "1000";
- if (args.length > 0)
- data = args[0];
! Drip drip = new Drip(254);
! TestDripMsg msg = new TestDripMsg();
! msg.set_data((short)Integer.parseInt(data));
! if (args.length > 1 && args[1].equals("wake")) {
drip.sendWakeup(msg, TestDripMsg.DEFAULT_MESSAGE_SIZE);
} else {
--- 184,210 ----
private void incrementSeqno() {
seqno = (seqno + 1) % 256;
! seqno = (seqno + 1) % 256;
!
! while ((seqno & ~DripConsts.DRIP_WAKEUP_BIT) == DripConsts.DRIP_SEQNO_OLDEST ||
! (seqno & ~DripConsts.DRIP_WAKEUP_BIT) == DripConsts.DRIP_SEQNO_NEWEST) {
!
! seqno = (seqno + 1) % 256;
seqno = (seqno + 1) % 256;
}
}
!
! private static int data = 1000;
! private static int channel = 254;
! private static boolean wakeup = false;
!
public static void main(String[] args) {
! parseArgs(args);
! Drip drip = new Drip(channel);
! TestDripMsg msg = new TestDripMsg();
! msg.set_data((short)data);
!
! if (wakeup) {
drip.sendWakeup(msg, TestDripMsg.DEFAULT_MESSAGE_SIZE);
} else {
***************
*** 198,200 ****
--- 213,262 ----
System.exit(0);
}
+
+ private static void parseArgs(String args[]) {
+
+ ArrayList cleanedArgs = new ArrayList();
+
+ for(int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("--")) {
+
+ // Parse Long Options
+ String longopt = args[i].substring(2);
+
+ if (longopt.equals("help")) {
+ usage();
+ }
+
+ } else if (args[i].startsWith("-")) {
+
+ // Parse Short Options
+ String opt = args[i].substring(1);
+
+ if (opt.equals("d")) {
+ data = Integer.parseInt(args[++i]);
+ } else if (opt.equals("w")) {
+ wakeup = true;
+ } else if (opt.equals("c")) {
+ channel = Integer.parseInt(args[++i]);
+ } else if (opt.equals("h")) {
+ usage();
+ }
+
+ } else {
+
+ // Place into args string
+ cleanedArgs.add(args[i]);
+ }
+ }
+ }
+
+ private static void usage() {
+ System.err.println("usage: java net.tinyos.drain.Drain <opts>");
+ System.err.println(" -d <data value>");
+ System.err.println(" -c <channel id>");
+ System.err.println(" -w : send message with wakeup bit set");
+ System.err.println(" -h, --help : this information");
+ System.exit(1);
+ }
+
}
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip Drip.h, 1.1,
1.2 DripC.nc, 1.2, 1.3 DripM.nc, 1.2, 1.3 DripStateM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip WakeupComm.h, NONE,
1.1 WakeupCommC.nc, NONE, 1.1 WakeupCommM.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-beta-commits
mailing list