[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/GGB/tools/java/net/tinyos/straw
Makefile, 1.3, 1.4 Straw.java, 1.4, 1.5 TestStraw.java, 1.1,
1.2 Counter.java, 1.1, NONE
Sukun Kim
binetude at users.sourceforge.net
Thu Nov 30 17:10:39 PST 2006
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/GGB/apps/TestStraw
TestStraw.h, NONE, 1.1 TestStraw.nc, NONE, 1.1 TestStrawM.nc,
NONE, 1.1 Makefile, 1.1, 1.2 README, 1.2, 1.3 DataCollector.h,
1.2, NONE DataCollector.nc, 1.1, NONE DataCollectorM.nc, 1.1, NONE
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/GGB/tools/java/net/tinyos/Zmgenj
CmdP.java, 1.2, NONE Counter.java, 1.2, NONE DataCenter.java,
1.4, NONE DriveTest.java, 1.5, NONE Makefile, 1.1,
NONE NodeList.java, 1.1, NONE README, 1.1, NONE Straw.java,
1.3, NONE TosP.java, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/GGB/tools/java/net/tinyos/straw
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8475
Modified Files:
Makefile Straw.java TestStraw.java
Removed Files:
Counter.java
Log Message:
Index: Makefile
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/GGB/tools/java/net/tinyos/straw/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile 9 Nov 2005 04:48:20 -0000 1.3
--- Makefile 1 Dec 2006 01:10:37 -0000 1.4
***************
*** 3,12 ****
LIB=$(TOSROOT)/contrib/GGB/tos/lib/Straw
MIG = mig java
INCLUDES = -I$(TOS)/lib/CC2420Radio
PLATFORM = micaz
- # List of message classes to build
MSGS = StrawBcastMsg.java StrawCmdMsg.java StrawReplyMsg.java StrawUARTMsg.java
! INITIAL_TARGETS = $(MSGS)
OTHER_CLEAN = cleanmig
--- 3,14 ----
LIB=$(TOSROOT)/contrib/GGB/tos/lib/Straw
MIG = mig java
+ NCG = ncg java
INCLUDES = -I$(TOS)/lib/CC2420Radio
PLATFORM = micaz
MSGS = StrawBcastMsg.java StrawCmdMsg.java StrawReplyMsg.java StrawUARTMsg.java
! CONSTS = StrawConsts.java
!
! INITIAL_TARGETS = $(MSGS) $(CONSTS)
OTHER_CLEAN = cleanmig
***************
*** 14,17 ****
--- 16,20 ----
include $(ROOT)/Makefile.include
+
StrawBcastMsg.java:
$(MIG) -target=$(PLATFORM) $(INCLUDES) -java-classname=$(PACKAGE).StrawBcastMsg $(LIB)/StrawBcast.h StrawBcastMsg -o $@
***************
*** 25,29 ****
StrawUARTMsg.java:
$(MIG) -target=$(PLATFORM) $(INCLUDES) -java-classname=$(PACKAGE).StrawUARTMsg $(LIB)/Straw.h StrawUARTMsg -o $@
!
cleanmig:
! rm -f $(MSGS)
--- 28,38 ----
StrawUARTMsg.java:
$(MIG) -target=$(PLATFORM) $(INCLUDES) -java-classname=$(PACKAGE).StrawUARTMsg $(LIB)/Straw.h StrawUARTMsg -o $@
!
!
! StrawConsts.java: $(LIB)/Straw.h
! $(NCG) -target=$(PLATFORM) $(INCLUDES) -java-classname=$(PACKAGE).StrawConsts -I$(LIB) $(LIB)/Straw.h Straw.h -o $@
!
!
cleanmig:
! rm -f $(MSGS) $(CONSTS)
!
Index: Straw.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/GGB/tools/java/net/tinyos/straw/Straw.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Straw.java 4 Aug 2005 23:18:51 -0000 1.4
--- Straw.java 1 Dec 2006 01:10:37 -0000 1.5
***************
*** 6,49 ****
import net.tinyos.message.*;
! class Straw implements MessageListener {
!
! // Straw.h //
! private static final short STRAW_TYPE_SHIFT = 10;
!
!
! private static final short STRAW_NETWORK_INFO = 1;
! private static final short STRAW_TRANSFER_DATA = 6;
! private static final short STRAW_RANDOM_READ = 7;
!
! private static final short STRAWCMDMSG_LENGTH
! = StrawCmdMsg.DEFAULT_MESSAGE_SIZE;
!
! private static final short STRAWCMDMSG_HEADER_LENGTH = 2;
! private static final short STRAWCMDMSG_ARG_LENGTH
! = STRAWCMDMSG_LENGTH - STRAWCMDMSG_HEADER_LENGTH;
! private static final short MAX_RANDOM_READ_SEQNO_SIZE
! = STRAWCMDMSG_ARG_LENGTH / 2;
!
!
! private static final short STRAW_NETWORK_INFO_REPLY = 1;
! private static final short STRAW_DATA_REPLY = 8;
!
! private static final short STRAWREPLYMSG_LENGTH
! = StrawReplyMsg.DEFAULT_MESSAGE_SIZE;
!
! private static final short STRAWREPLYMSG_HEADER_LENGTH = 0;
! private static final short STRAWREPLYMSG_ARG_LENGTH
! = STRAWREPLYMSG_LENGTH - STRAWREPLYMSG_HEADER_LENGTH;
! private static final short MAX_DATA_REPLY_DATA_SIZE
! = STRAWREPLYMSG_ARG_LENGTH - 2;
!
// StrawM.nc //
! private static final short RADIUS_OF_INTERFERENCE = 3;
! private static short UART_ONLY_DELAY =
! ((STRAWREPLYMSG_LENGTH + 7) * 7 + 157) / 36;
! private static short UART_DELAY = ((STRAWREPLYMSG_LENGTH + 7) * 7 + 85) / 36;
! private static short RADIO_DELAY = 9;
! // = ((STRAWREPLYMSG_LENGTH + 7) * 7 + 234) / 19;
--- 6,20 ----
import net.tinyos.message.*;
! public class Straw implements MessageListener {
// StrawM.nc //
! private static final short RADIUS_OF_INTERFERENCE = 5;
! private static short UART_ONLY_DELAY
! = ((StrawConsts.STRAWREPLYMSG_LENGTH + 7) * 7 + 157) / 36;
! private static short UART_DELAY
! = ((StrawConsts.STRAWREPLYMSG_LENGTH + 7) * 7 + 85) / 36;
! private static short RADIO_DELAY
! //= ((StrawConsts.STRAWREPLYMSG_LENGTH + 7) * 7 + 234) / 19;//65;
! = ((StrawConsts.STRAWREPLYMSG_LENGTH + 7) * 7 + 234) / 50;
***************
*** 51,68 ****
private static final short MAX_SEND_TRY = 10;
private static final short UNCERTAINTY = 1;
! private static final short DIVERGE_HEADER_LENGTH = 2;
! private static final short CONVERGE_HEADER_LENGTH = 7;
- // Arguments //
static final short TOS_BCAST_ADDR = (short)0xffff;
private int dest;
! short toUART = 0; // You can directly access a mote
! // (like through testbed)
private long start;
private long size;
private byte[] bffr;
private int seqSize;
--- 22,45 ----
private static final short MAX_SEND_TRY = 10;
private static final short UNCERTAINTY = 1;
! private static final short MAX_HOP_CNT = 50;
! private static final short SFTY_FCTR = 1000;
+ private static final short PAUSE_BETWEEN_STATES
+ = MAX_HOP_CNT * 30 * (2 + UNCERTAINTY) + SFTY_FCTR;
static final short TOS_BCAST_ADDR = (short)0xffff;
+
+ // Arguments //
private int dest;
! private short portId;
private long start;
private long size;
private byte[] bffr;
private int seqSize;
+
+ public short toUART = 0; // You can directly access a mote
+ // (like through testbed)
+ public short verbose = 5; // Set the amount of information for debugging
***************
*** 73,78 ****
}
private StrawBcastMsg bcastMsg = new StrawBcastMsg(); // only for Bcast
! private StrawCmdMsg cmdMsg = new StrawCmdMsg(bcastMsg, DIVERGE_HEADER_LENGTH);
! Counter bcastSeqNo = new Counter("SMT_BcastSeqNo.txt"); // only for Bcast
private boolean msgArrvd;
--- 50,55 ----
}
private StrawBcastMsg bcastMsg = new StrawBcastMsg(); // only for Bcast
! private StrawCmdMsg cmdMsg = new StrawCmdMsg(bcastMsg,
! StrawConsts.DIVERGE_HEADER_LENGTH);
private boolean msgArrvd;
***************
*** 85,90 ****
private int msngSeqNoIndex;
! private int rrSeqNo[] = new int[MAX_RANDOM_READ_SEQNO_SIZE];
! int sizeOfRrSeqNo;
--- 62,71 ----
private int msngSeqNoIndex;
! private int rrSeqNo[] = new int[StrawConsts.MAX_RANDOM_READ_SEQNO_SIZE];
! private int sizeOfRrSeqNo;
!
! // For checking error //
! private int checksum;
! private int tmpCheckSum;
***************
*** 97,102 ****
--- 78,89 ----
private long endOfTd;
private long endOfRr;
+ private long endOfEc;
private long successRate;
+ // Et Cetra //
+ private short state = StrawConsts.STRAW_IDLE_STATE;
+ private int symbolChar;
+ private int symbolLine;
+
***************
*** 107,110 ****
--- 94,98 ----
} catch (InterruptedException e) {
System.out.println("EXCEPTION: Straw.easyWait");
+ return 1;
}
}
***************
*** 113,150 ****
private int sendMsg(short type) {
cmdMsg.set_dest(dest);
switch (type) {
! case STRAW_NETWORK_INFO:
cmdMsg.set_arg_ni_type(type);
- cmdMsg.set_arg_ni_uartOnlyDelay(UART_ONLY_DELAY);
- cmdMsg.set_arg_ni_uartDelay(UART_DELAY);
- cmdMsg.set_arg_ni_radioDelay(RADIO_DELAY);
cmdMsg.set_arg_ni_toUART(toUART);
break;
! case STRAW_TRANSFER_DATA:
cmdMsg.set_arg_td_type(type);
cmdMsg.set_arg_td_start(start);
cmdMsg.set_arg_td_size(size);
cmdMsg.set_arg_td_toUART(toUART);
break;
! case STRAW_RANDOM_READ:
! for (int i = 0; i < MAX_RANDOM_READ_SEQNO_SIZE; i++) {
if (rrSeqNo[i] == 0xffff) {
! cmdMsg.setElement_arg_rr_seqNo(i, STRAW_RANDOM_READ);
break;
}
! cmdMsg.setElement_arg_rr_seqNo(i, rrSeqNo[i] + STRAW_TYPE_SHIFT);
}
break;
default:
System.out.println("ERROR: Straw.sendMsg");
! break;
}
! bcastMsg.set_seqno(bcastSeqNo.get());
! bcastSeqNo.incr();
! System.out.print("S");
try {
mote.send(TOS_BCAST_ADDR, bcastMsg);
--- 101,149 ----
+
private int sendMsg(short type) {
cmdMsg.set_dest(dest);
switch (type) {
! case StrawConsts.STRAW_NETWORK_INFO:
cmdMsg.set_arg_ni_type(type);
cmdMsg.set_arg_ni_toUART(toUART);
break;
! case StrawConsts.STRAW_TRANSFER_DATA:
cmdMsg.set_arg_td_type(type);
+ cmdMsg.set_arg_td_portId(portId);
cmdMsg.set_arg_td_start(start);
cmdMsg.set_arg_td_size(size);
+
+ cmdMsg.set_arg_td_uartOnlyDelay(UART_ONLY_DELAY);
+ cmdMsg.set_arg_td_uartDelay(UART_DELAY);
+ cmdMsg.set_arg_td_radioDelay(RADIO_DELAY);
cmdMsg.set_arg_td_toUART(toUART);
break;
! case StrawConsts.STRAW_RANDOM_READ:
! for (int i = 0; i < StrawConsts.MAX_RANDOM_READ_SEQNO_SIZE; i++) {
if (rrSeqNo[i] == 0xffff) {
! cmdMsg.setElement_arg_rr_seqNo(i, StrawConsts.STRAW_RANDOM_READ);
break;
}
! cmdMsg.setElement_arg_rr_seqNo(i, rrSeqNo[i]
! + StrawConsts.STRAW_TYPE_SHIFT);
}
break;
+ case StrawConsts.STRAW_ERR_CHK:
+ cmdMsg.set_arg_ec_type(type);
+ cmdMsg.set_arg_ec_toUART(toUART);
+ break;
default:
System.out.println("ERROR: Straw.sendMsg");
! return 1;
}
! bcastMsg.set_seqno((short)0);
! if (verbose >= 6) { System.out.print(cmdMsg); }
! else if (verbose >= 1) {
! printSymbol("S");
! if (verbose >= 4) System.out.print(cmdMsg.get_arg_cd_type() + "");
! }
try {
mote.send(TOS_BCAST_ADDR, bcastMsg);
***************
*** 152,165 ****
} catch (IOException e) {
System.out.println("EXCEPTION: Straw.sendMsg - mote.send failed");
}
return 0;
}
! private boolean sendMsgGetReply(short type) {
msgArrvd = false;
sendMsg(type);
! easyWait(maxRTT);
! if (!msgArrvd)
! System.out.println("Node " + dest + " does not respond");
return msgArrvd;
}
--- 151,170 ----
} catch (IOException e) {
System.out.println("EXCEPTION: Straw.sendMsg - mote.send failed");
+ return 2;
}
return 0;
}
! private boolean sendMsgGetReply(short type, int dur) {
msgArrvd = false;
sendMsg(type);
! easyWait(dur);
! if (!msgArrvd) {
! if (verbose >= 1) {
! printSymbol(".");
! if (verbose >= 4)
! System.out.println("Node " + dest + " does not respond");
! }
! }
return msgArrvd;
}
***************
*** 168,174 ****
int i;
for (i = 0; i < MAX_SEND_TRY; i++)
! if (sendMsgGetReply(type)) break;
if (i == MAX_SEND_TRY) {
! System.out.println("[Rlb] Node " + dest + " does not respond");
return false;
} else {
--- 173,188 ----
int i;
for (i = 0; i < MAX_SEND_TRY; i++)
! if (sendMsgGetReply(type, maxRTT)) break;
if (i == MAX_SEND_TRY) {
! for (i = 0; i < MAX_SEND_TRY; i++)
! if (sendMsgGetReply(type, 2 * maxRTT)) break;
! }
! if (i == MAX_SEND_TRY) {
! for (i = 0; i < MAX_SEND_TRY; i++)
! if (sendMsgGetReply(type, 8 * maxRTT)) break;
! }
! if (i == MAX_SEND_TRY) {
! if (verbose >= 4)
! System.out.println("[Rlb] Node " + dest + " does not respond");
return false;
} else {
***************
*** 181,188 ****
++msgRcvd;
StrawReplyMsg reply;
! reply = new StrawReplyMsg(msg, CONVERGE_HEADER_LENGTH);
! System.out.print("R");
! if (reply.get_arg_cdr_type() == STRAW_NETWORK_INFO_REPLY) {
if (toUART != 0) {
maxRTT = UART_ONLY_DELAY * (2 + UNCERTAINTY)
--- 195,211 ----
++msgRcvd;
StrawReplyMsg reply;
! reply = new StrawReplyMsg(msg, StrawConsts.CONVERGE_HEADER_LENGTH);
! if (verbose >= 6) {
! System.out.print(reply);
! } else if (verbose >= 1) {
! printSymbol("R");
! if (verbose >= 4) System.out.print(reply.get_arg_cdr_type() + "");
! }
! if (reply.get_arg_cdr_type() == StrawConsts.STRAW_NETWORK_INFO_REPLY &&
! state == StrawConsts.STRAW_NETWORK_INFO) {
! //UART_ONLY_DELAY = (short)reply.get_arg_nir_uartOnlyDelay();
! //UART_DELAY = (short)reply.get_arg_nir_uartDelay();
! //RADIO_DELAY = (short)reply.get_arg_nir_radioDelay();
if (toUART != 0) {
maxRTT = UART_ONLY_DELAY * (2 + UNCERTAINTY)
***************
*** 198,213 ****
}
! } else if (reply.get_arg_cdr_type() >= STRAW_TYPE_SHIFT) {
! lastRcvdSeqNo = reply.get_arg_dr_seqNo() - STRAW_TYPE_SHIFT;
! int writingSize = (lastRcvdSeqNo + 1) * MAX_DATA_REPLY_DATA_SIZE > size
! ? (int)(size - lastRcvdSeqNo * MAX_DATA_REPLY_DATA_SIZE)
! : MAX_DATA_REPLY_DATA_SIZE;
for (int i = 0; i < writingSize; i++)
! bffr[lastRcvdSeqNo * MAX_DATA_REPLY_DATA_SIZE + i]
= (byte)reply.getElement_arg_dr_data(i);
rcvdSeqNo[lastRcvdSeqNo] = true;
} else {
! System.out.println("ERROR: Straw.messageReceived - invalid type");
}
--- 221,246 ----
}
! } else if (reply.get_arg_cdr_type() >= StrawConsts.STRAW_TYPE_SHIFT &&
! (state == StrawConsts.STRAW_TRANSFER_DATA
! || state == StrawConsts.STRAW_RANDOM_READ)) {
! lastRcvdSeqNo = reply.get_arg_dr_seqNo() - StrawConsts.STRAW_TYPE_SHIFT;
! int writingSize
! = (lastRcvdSeqNo + 1) * StrawConsts.MAX_DATA_REPLY_DATA_SIZE > size
! ? (int)(size - lastRcvdSeqNo * StrawConsts.MAX_DATA_REPLY_DATA_SIZE)
! : StrawConsts.MAX_DATA_REPLY_DATA_SIZE;
for (int i = 0; i < writingSize; i++)
! bffr[lastRcvdSeqNo * StrawConsts.MAX_DATA_REPLY_DATA_SIZE + i]
= (byte)reply.getElement_arg_dr_data(i);
rcvdSeqNo[lastRcvdSeqNo] = true;
+ } else if (reply.get_arg_cdr_type() == StrawConsts.STRAW_ERR_CHK_REPLY &&
+ state == StrawConsts.STRAW_ERR_CHK) {
+ checksum = reply.get_arg_ecr_checksum();
+
} else {
! System.out.println("\n" + "ERROR: Straw.messageReceived - invalid type");
! if (verbose >= 3) System.out.println("state = " + state
! + ", type = " + reply.get_arg_cdr_type());
! return;
}
***************
*** 220,234 ****
! int read(int dest, long start, long size, byte[] bffr) {
System.out.println("**** Straw ****");
! if (size == 0) return 0;
this.dest = dest;
this.start = start;
this.size = size;
this.bffr = bffr;
! seqSize = (int)((size + MAX_DATA_REPLY_DATA_SIZE - 1)
! / MAX_DATA_REPLY_DATA_SIZE);
maxRTT = (UART_DELAY + 3 * RADIO_DELAY) * (2 + UNCERTAINTY)
! + RADIUS_OF_INTERFERENCE * RADIO_DELAY + 10;
rcvdSeqNo = new boolean[seqSize];
--- 253,283 ----
! public int ping(int dest, short portId) {
! System.out.println("**** Ping ****");
! if (state != StrawConsts.STRAW_IDLE_STATE) return 1;
! state = StrawConsts.STRAW_NETWORK_INFO;
! if (!sendMsgGetReplyRlb(StrawConsts.STRAW_NETWORK_INFO)) return 2;
! state = StrawConsts.STRAW_IDLE_STATE;
! return 0;
! }
!
!
!
! public int read(int dest, short portId, long start, long size, byte[] bffr) {
System.out.println("**** Straw ****");
! if (size == 0) { System.out.println("Straw Success: size = 0");
! return 0; }
! if (state != StrawConsts.STRAW_IDLE_STATE) return rptFail(1);
!
this.dest = dest;
+ this.portId = portId;
this.start = start;
this.size = size;
this.bffr = bffr;
! seqSize = (int)((size + StrawConsts.MAX_DATA_REPLY_DATA_SIZE - 1)
! / StrawConsts.MAX_DATA_REPLY_DATA_SIZE);
maxRTT = (UART_DELAY + 3 * RADIO_DELAY) * (2 + UNCERTAINTY)
! + RADIUS_OF_INTERFERENCE * RADIO_DELAY + 10
! + 500;
rcvdSeqNo = new boolean[seqSize];
***************
*** 238,247 ****
msgRcvd = 0;
timeOfMoment = new Date();
endOfInit = timeOfMoment.getTime();
! // Get network info //
! if (!sendMsgGetReplyRlb(STRAW_NETWORK_INFO)) return 1;
timeOfMoment = new Date();
endOfNi = timeOfMoment.getTime();
--- 287,301 ----
msgRcvd = 0;
+ symbolChar = 0;
+ symbolLine = 1;
+
timeOfMoment = new Date();
endOfInit = timeOfMoment.getTime();
! // Get network info //
! state = StrawConsts.STRAW_NETWORK_INFO;
! easyWait(PAUSE_BETWEEN_STATES);
! if (!sendMsgGetReplyRlb(StrawConsts.STRAW_NETWORK_INFO)) return rptFail(2);
timeOfMoment = new Date();
endOfNi = timeOfMoment.getTime();
***************
*** 250,257 ****
// Ask transfer of data //
lastRcvdSeqNo = 0;
! if (!sendMsgGetReplyRlb(STRAW_TRANSFER_DATA)) return 2; // only for Bcast
! ////sendMsg(STRAW_TRANSFER_DATA) // only for Drip
msgArrvd = true;
while ((lastRcvdSeqNo < seqSize - 1) && msgArrvd) { // !last && !timeout
--- 304,312 ----
// Ask transfer of data //
+ state = StrawConsts.STRAW_TRANSFER_DATA;
+ easyWait(PAUSE_BETWEEN_STATES);
lastRcvdSeqNo = 0;
! if (!sendMsgGetReplyRlb(StrawConsts.STRAW_TRANSFER_DATA)) return rptFail(3);
msgArrvd = true;
while ((lastRcvdSeqNo < seqSize - 1) && msgArrvd) { // !last && !timeout
***************
*** 259,275 ****
easyWait((seqSize - lastRcvdSeqNo - 1) * pktIntrv + pktIntrv / 2);
}
timeOfMoment = new Date();
endOfTd = timeOfMoment.getTime();
- successRate = msgRcvd - successRate;
// Fill missing holes using random read //
msngSeqNoIndex = 0;
rrSeqNo[0] = 0xffff;
- ////int rrFailCnt = 0; // only for Drip
while(hasMore()) {
! if(!sendMsgGetReplyRlb(STRAW_RANDOM_READ)) return 3; // only for Bcast
! ////sendMsg(STRAW_RANDOM_READ); // only for Drip
int rrSeqNoIndex = 0;
msgArrvd = true;
--- 314,331 ----
easyWait((seqSize - lastRcvdSeqNo - 1) * pktIntrv + pktIntrv / 2);
}
+ successRate = msgRcvd - successRate;
+ if (verbose >= 2) System.out.println("\n" + getStatString());
timeOfMoment = new Date();
endOfTd = timeOfMoment.getTime();
// Fill missing holes using random read //
+ state = StrawConsts.STRAW_RANDOM_READ;
+ easyWait(PAUSE_BETWEEN_STATES);
msngSeqNoIndex = 0;
rrSeqNo[0] = 0xffff;
while(hasMore()) {
! if(!sendMsgGetReplyRlb(StrawConsts.STRAW_RANDOM_READ)) return rptFail(4);
int rrSeqNoIndex = 0;
msgArrvd = true;
***************
*** 278,289 ****
msgArrvd = false;
easyWait((sizeOfRrSeqNo - rrSeqNoIndex) * pktIntrv + pktIntrv / 2);
! if (msgArrvd)
! for (; rrSeqNoIndex < sizeOfRrSeqNo; rrSeqNoIndex++)
if (rrSeqNo[rrSeqNoIndex] == lastRcvdSeqNo) {
++rrSeqNoIndex;
break;
}
! ////rrFailCnt = msgArrvd ? 0 : rrFailCnt + 1; // only for Drip
! ////if (rrFailCnt >= MAX_SEND_TRY) return 3; // only for Drip
}
}
--- 334,347 ----
msgArrvd = false;
easyWait((sizeOfRrSeqNo - rrSeqNoIndex) * pktIntrv + pktIntrv / 2);
! if (msgArrvd) {
! for (rrSeqNoIndex = 0; rrSeqNoIndex < sizeOfRrSeqNo; rrSeqNoIndex++)
if (rrSeqNo[rrSeqNoIndex] == lastRcvdSeqNo) {
++rrSeqNoIndex;
break;
}
! if (rrSeqNoIndex == sizeOfRrSeqNo) {
! rrSeqNoIndex = 0;
! }
! }
}
}
***************
*** 292,297 ****
! System.out.println("");
! System.out.println(getStatString());
return 0;
}
--- 350,372 ----
! // Error Check //
! state = StrawConsts.STRAW_ERR_CHK;
! easyWait(PAUSE_BETWEEN_STATES);
! if (!sendMsgGetReplyRlb(StrawConsts.STRAW_ERR_CHK)) return rptFail(5);
! tmpCheckSum = 0;
! for (int i = 0; i < size; i++) {
! tmpCheckSum += (int)bffr[i] < 0 ? (int)bffr[i] + 256 : (int)bffr[i];
! tmpCheckSum %= 65536;
! }
! if (checksum != tmpCheckSum) return rptFail(6);
! timeOfMoment = new Date();
! endOfEc = timeOfMoment.getTime();
!
!
! // Print Statistics //
! state = StrawConsts.STRAW_IDLE_STATE;
! if (verbose >= 1) System.out.println("\n" + getPerfString());
! if (verbose >= 2) System.out.println(getStatString());
! System.out.println("Straw Success");
return 0;
}
***************
*** 303,307 ****
// Compact rrSeqNo //
sizeOfRrSeqNo = 0;
! for (int i = 0; i < MAX_RANDOM_READ_SEQNO_SIZE; i++) {
if (rrSeqNo[i] == 0xffff) {
break;
--- 378,382 ----
// Compact rrSeqNo //
sizeOfRrSeqNo = 0;
! for (int i = 0; i < StrawConsts.MAX_RANDOM_READ_SEQNO_SIZE; i++) {
if (rrSeqNo[i] == 0xffff) {
break;
***************
*** 314,318 ****
// Fill rrSeqNo //
while (true) {
! if (sizeOfRrSeqNo == MAX_RANDOM_READ_SEQNO_SIZE) break; // full rrSeqNo
// Find a new hole //
--- 389,395 ----
// Fill rrSeqNo //
while (true) {
! if (sizeOfRrSeqNo == StrawConsts.MAX_RANDOM_READ_SEQNO_SIZE)
! // full rrSeqNo
! break;
// Find a new hole //
***************
*** 330,336 ****
// Wrap up and return //
if (sizeOfRrSeqNo == 0) { // no missing hole
return false;
! } else if (sizeOfRrSeqNo < MAX_RANDOM_READ_SEQNO_SIZE) { // Partial rrSeqNo
rrSeqNo[sizeOfRrSeqNo] = 0xffff;
return true;
--- 407,417 ----
// Wrap up and return //
+ if (verbose >= 3 && sizeOfRrSeqNo > 0) {
+ System.out.println("#" + rrSeqNo[sizeOfRrSeqNo - 1] + "#");
+ }
if (sizeOfRrSeqNo == 0) { // no missing hole
return false;
! } else if (sizeOfRrSeqNo < StrawConsts.MAX_RANDOM_READ_SEQNO_SIZE) {
! // Partial rrSeqNo
rrSeqNo[sizeOfRrSeqNo] = 0xffff;
return true;
***************
*** 340,351 ****
}
private String getStatString() {
return "msgSent = " + msgSent + ", msgRcvd = " + msgRcvd
+ ", successRate = " + ((double)successRate / (double)seqSize)
+ " (" + successRate + " / " + seqSize + ")" + "\n"
+ "Ni = " + (endOfNi - endOfInit)
+ ", Td = " + (endOfTd - endOfNi) + ", Rr = " + (endOfRr - endOfTd)
! + ", total = " + (endOfRr - endOfInit) + "\n";
}
--- 421,473 ----
}
+
+
private String getStatString() {
return "msgSent = " + msgSent + ", msgRcvd = " + msgRcvd
+ ", successRate = " + ((double)successRate / (double)seqSize)
+ " (" + successRate + " / " + seqSize + ")" + "\n"
+
+ + "checksum = " + checksum
+ + ", tmpCheckSum = " + tmpCheckSum + "\n"
+ "Ni = " + (endOfNi - endOfInit)
+ ", Td = " + (endOfTd - endOfNi) + ", Rr = " + (endOfRr - endOfTd)
! + ", Ec = " + (endOfEc - endOfRr)
! + ", total = " + (endOfEc - endOfInit) + "\n";
! }
!
! private String getPerfString() {
! double latency = (double)(endOfEc - endOfInit) / 1000;
! double bandwidth = (double)size / latency;
! double chnlCpcty = ((double)seqSize / (double)(endOfTd - endOfNi)) * 1000
! * ((double)successRate / (double)seqSize)
! * StrawReplyMsg.DEFAULT_MESSAGE_SIZE;
! chnlCpcty = 106 * 22;
! return "Bandwidth = " + bandwidth + " (B/s)\n"
! + "Latency = " + latency + " (s)\n";
! //+ "Channel Utilization = " + (bandwidth * 100 / chnlCpcty) + " (%)\n";
! }
!
! private int rptFail(int errCd) {
! state = StrawConsts.STRAW_IDLE_STATE;
! System.out.println("Straw Fail: " + errCd);
! if (verbose >= 3) System.out.println("\n" + getPerfString());
! if (verbose >= 3) System.out.println(getStatString());
! return errCd;
! }
!
! private void printSymbol(String outSymbol) {
! if (symbolChar == 0) {
! if (symbolLine < 100) System.out.print(" ");
! if (symbolLine < 10) System.out.print(" ");
! System.out.print(symbolLine + ":");
! }
! System.out.print(outSymbol);
! symbolChar++;
! if (symbolChar >= 70) {
! symbolChar = 0;
! symbolLine++;
! System.out.println("");
! }
}
Index: TestStraw.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/GGB/tools/java/net/tinyos/straw/TestStraw.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestStraw.java 1 Dec 2006 00:26:12 -0000 1.1
--- TestStraw.java 1 Dec 2006 01:10:37 -0000 1.2
***************
*** 2,16 ****
public class DataCenter {
- // Counter bcastSeqNo = new Counter("SMT_BcastSeqNo.txt"); // only for Bcast
Straw straw = new Straw();
public int execute(String[] args) {
! short dest = 1;
long start = 0;
! long size = 20000;
byte[] data = new byte[(int)size];
! // bcastSeqNo.reset();
! straw.read(dest, start, size, data);
return 0;
--- 2,15 ----
public class DataCenter {
Straw straw = new Straw();
public int execute(String[] args) {
! int dest = 1;
! short portId = 2;
long start = 0;
! long size = 10000;
byte[] data = new byte[(int)size];
! straw.read(dest, start, portId, size, data);
return 0;
--- Counter.java DELETED ---
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/GGB/apps/TestStraw
TestStraw.h, NONE, 1.1 TestStraw.nc, NONE, 1.1 TestStrawM.nc,
NONE, 1.1 Makefile, 1.1, 1.2 README, 1.2, 1.3 DataCollector.h,
1.2, NONE DataCollector.nc, 1.1, NONE DataCollectorM.nc, 1.1, NONE
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/GGB/tools/java/net/tinyos/Zmgenj
CmdP.java, 1.2, NONE Counter.java, 1.2, NONE DataCenter.java,
1.4, NONE DriveTest.java, 1.5, NONE Makefile, 1.1,
NONE NodeList.java, 1.1, NONE README, 1.1, NONE Straw.java,
1.3, NONE TosP.java, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list