[Tinyos-2-commits]
CVS: tinyos-2.x/support/sdk/java/net/tinyos/packet
Packetizer.java, 1.5, 1.6
dmm
rincon at users.sourceforge.net
Fri May 18 11:53:26 PDT 2007
Update of /cvsroot/tinyos/tinyos-2.x/support/sdk/java/net/tinyos/packet
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21648/net/tinyos/packet
Modified Files:
Packetizer.java
Log Message:
Automatic retries if the mote doesn't send back a proper ack. This helps work around the tmote dropped packet issue.
Index: Packetizer.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/support/sdk/java/net/tinyos/packet/Packetizer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Packetizer.java 18 May 2007 18:27:04 -0000 1.5
--- Packetizer.java 18 May 2007 18:53:24 -0000 1.6
***************
*** 32,35 ****
--- 32,36 ----
import net.tinyos.util.*;
+
import java.io.*;
import java.util.*;
***************
*** 116,120 ****
synchronized public void open(Messenger messages) throws IOException {
super.open(messages);
! if(!reader.isAlive()) {
reader.start();
}
--- 117,121 ----
synchronized public void open(Messenger messages) throws IOException {
super.open(messages);
! if (!reader.isAlive()) {
reader.start();
}
***************
*** 182,189 ****
// Write an ack-ed packet
protected boolean writeSourcePacket(byte[] packet) throws IOException {
! writeFramedPacket(P_PACKET_ACK, ++seqNo, packet, packet.length);
- long deadline = System.currentTimeMillis() + ACK_TIMEOUT;
- for (;;) {
byte[] ack = readProtocolPacket(P_ACK, deadline);
if (ack == null) {
--- 183,191 ----
// Write an ack-ed packet
protected boolean writeSourcePacket(byte[] packet) throws IOException {
! for (int retries = 0; retries < 25; retries++) {
! writeFramedPacket(P_PACKET_ACK, ++seqNo, packet, packet.length);
!
! long deadline = System.currentTimeMillis() + ACK_TIMEOUT;
byte[] ack = readProtocolPacket(P_ACK, deadline);
if (ack == null) {
***************
*** 191,195 ****
message(name + ": ACK timed out");
}
! return false;
}
if (ack[0] == (byte) seqNo) {
--- 193,197 ----
message(name + ": ACK timed out");
}
! continue;
}
if (ack[0] == (byte) seqNo) {
***************
*** 201,204 ****
--- 203,207 ----
}
+ return false;
}
More information about the Tinyos-2-commits
mailing list