[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/delugetools Deluge.java, 1.10, 1.11 Eraser.java, 1.5, 1.6

Jonathan Hui jwhui at users.sourceforge.net
Thu Jun 9 15:12:28 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23487

Modified Files:
	Deluge.java Eraser.java 
Log Message:
- Added support to reset version number for an image. The operation
can only occur if directly connected to the PC and is not
epidemic. Supports cases where users want to shift nodes between
networks.



Index: Deluge.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools/Deluge.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Deluge.java	17 May 2005 20:57:16 -0000	1.10
--- Deluge.java	9 Jun 2005 22:12:25 -0000	1.11
***************
*** 45,49 ****
    private static final int S_REBOOT = 3;
    private static final int S_ERASE = 4;
!   private static final int S_DUMP = 5;
  
    private int mode = S_NONE;
--- 45,50 ----
    private static final int S_REBOOT = 3;
    private static final int S_ERASE = 4;
!   private static final int S_RESET = 5;
!   private static final int S_DUMP = 6;
  
    private int mode = S_NONE;
***************
*** 66,70 ****
      + "   -i,  --inject          : inject a binary\n"
      + "   -r,  --reboot          : send reboot command\n"
!     + "   -e,  --erase           : erase an object\n"
      + "   -d,  --dump            : dumps data injected to node\n"
      + "  options are:\n"
--- 67,72 ----
      + "   -i,  --inject          : inject a binary\n"
      + "   -r,  --reboot          : send reboot command\n"
!     + "   -e,  --erase           : erase a binary\n"
!     + "   -x,  --reset           : reset image\n"
      + "   -d,  --dump            : dumps data injected to node\n"
      + "  options are:\n"
***************
*** 101,104 ****
--- 103,110 ----
  	modeCount++;
        }
+       else if (args[i].equals("-x") || args[i].equals("--reset")) {
+ 	mode = S_RESET;
+ 	modeCount++;
+       }
        else if (args[i].equals("-d") || args[i].equals("--dump")) {
  	mode = S_DUMP;
***************
*** 250,254 ****
  
        break;
!       
      case S_REBOOT:
  
--- 256,272 ----
  
        break;
! 
!     case S_RESET:
! 
!       if (imageNum < 1 || imageNum >= pinger.getNumImages()) {
!         throw new IllegalArgumentException( "invalid image number" );
!       }
! 
!       Eraser resetter = new Eraser(pinger, imageNum, moteif, verbose, force);
! 
!       resetter.reset();
! 
!       break;
! 
      case S_REBOOT:
  

Index: Eraser.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools/Eraser.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Eraser.java	5 May 2005 02:18:48 -0000	1.5
--- Eraser.java	9 Jun 2005 22:12:25 -0000	1.6
***************
*** 67,70 ****
--- 67,132 ----
    }
  
+   public void reset() {
+ 
+     if ( advMsg.get_sourceAddr() == MoteIF.TOS_BCAST_ADDR ) {
+       throw new IllegalArgumentException(
+ 	"This operation requires a direct connection to the node." );
+     }
+ 
+     System.out.println("Reset image:");
+     System.out.println("  Image: " + pingReply.get_imgDesc_imgNum());
+     if (oldTOSBootImage != null) {
+       System.out.println(oldTOSBootImage);
+     }
+     else {
+       System.out.println("    No metadata associated with this image.");
+     }
+ 
+     System.out.println();
+     System.out.println("--------------------------------------------------");
+     System.out.println("| WARNING: This operation allows the currently   |");
+     System.out.println("|          connected node to receive any image   |");
+     System.out.println("|          even if they are older. This          |");
+     System.out.println("|          operation is not epidemic and will    |");
+     System.out.println("|          only affect this node.                |");
+     System.out.println("--------------------------------------------------");
+     System.out.println();
+ 
+     if( !force )
+     {
+       System.out.print("Continue operation? (y/[n]) " );
+       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+       try {
+ 	for (;;) {
+ 	  String ans = in.readLine();
+ 	  ans = ans.toLowerCase();
+ 	  if (ans.equals("") || ans.equals("n") || ans.equals("no")) {
+ 	    throw new IllegalArgumentException("operation cancelled");
+ 	  }
+ 	  if (ans.equals("y") || ans.equals("yes"))
+ 	    break;
+ 	  System.out.print("Please enter yes or no: ");
+ 	}
+       } catch (IOException e) {
+ 	e.printStackTrace();
+       }
+     }
+ 
+     advMsg.set_imgDesc_vNum(DelugeConsts.DELUGE_INVALID_VNUM);
+ 
+     moteif.registerListener(new DelugeAdvMsg(), this);
+ 
+     while(!injectAcked) {
+       try {
+ 	advMsg = DelugeCrc.computeAdvCrc(advMsg);
+ 	send(advMsg);
+ 	if (verbose) System.out.print(advMsg);
+ 	Thread.currentThread().sleep(1000);
+       } catch (Exception e) {
+ 	e.printStackTrace();
+       }
+     }    
+   }
+ 
    public void erase() {
  



More information about the Tinyos-beta-commits mailing list