[Tinyos-2-commits] CVS: tinyos-2.x/tools/tinyos/misc tos-deluge, 1.3, 1.4

Razvan Musaloiu-E. razvanm at users.sourceforge.net
Mon Jul 9 18:17:42 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26582/tools/tinyos/misc

Modified Files:
	tos-deluge 
Log Message:
This commit from Chieh-Jan (Mike) Liang fixes the following issues:
- Add a new command to reprogram the network (instead of motes automatically reprogram after they receive an image).
- Update the documentation to reflect the new command.
- Add README.txt files for the examples.


Index: tos-deluge
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc/tos-deluge,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tos-deluge	2 Jun 2007 00:09:15 -0000	1.3
--- tos-deluge	10 Jul 2007 01:17:40 -0000	1.4
***************
*** 48,56 ****
  
  # Serial message types
! MSG_ERASE  = 0
! MSG_WRITE  = 1
! MSG_READ   = 2
! MSG_REPROG = 5
! MSG_DISS   = 6
  
  ERROR_SUCCESS = 0   # T2-compatible
--- 48,57 ----
  
  # Serial message types
! MSG_ERASE     = 0
! MSG_WRITE     = 1
! MSG_READ      = 2
! MSG_REPROG    = 5
! MSG_DISS      = 6
! MSG_REPROG_BS = 7
  
  ERROR_SUCCESS = 0   # T2-compatible
***************
*** 321,330 ****
      return False
  
! # Requests the mote to reboot and reprogram itself
! def op_reprog(s, img_num):
      if getMetaData(s, img_num) == None:
          print "ERROR: No proper Deluge image found!"
      else:
!         sreqpkt = SerialReqPacket((MSG_REPROG, img_num, 0, 0, []))
          success = s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload())
          if success == True:
--- 322,331 ----
      return False
  
! # Requests the base station to reprogram itself
! def op_reprog_bs(s, img_num):
      if getMetaData(s, img_num) == None:
          print "ERROR: No proper Deluge image found!"
      else:
!         sreqpkt = SerialReqPacket((MSG_REPROG_BS, img_num, 0, 0, []))
          success = s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload())
          if success == True:
***************
*** 334,338 ****
                  return True
              else:
!                 print "ERROR: Unable to reboot the mote"
                  return False
              
--- 335,339 ----
                  return True
              else:
!                 print "ERROR: Unable to reprogram the base station"
                  return False
              
***************
*** 340,343 ****
--- 341,359 ----
      return False
  
+ # Requests the network to reprogram with the specified image number
+ def op_reprog(s, img_num):
+     sreqpkt = SerialReqPacket((MSG_REPROG, img_num, 0, 0, []))
+     success = s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload())
+     if success == True:
+         packet = s.read_packet(SERIAL_AMGROUP, SERIAL_AMID)
+         sreplypkt = SerialReplyPacket(packet[1])
+         if sreplypkt.error == ERROR_SUCCESS:
+             return True
+         else:
+             print "ERROR: Unable to reprogram the network"
+             return False
+         
+     print "ERROR: Unable to send the command"
+ 
  # Requests the mote to disseminate an image
  def op_diss(s, img_num):
***************
*** 387,391 ****
      print "  -i --inject\n     Inject a compiled TinyOS application"
      print "      [options]: tos_image.xml file path"
!     print "  -r --reboot\n     Reboot and reprogram the directly-connected mote"
      print "  -d --dissemination\n     Disseminate the image in the external flash to the network"
      print "  -e --erase\n     Erase an image in the external flash"
--- 403,408 ----
      print "  -i --inject\n     Inject a compiled TinyOS application"
      print "      [options]: tos_image.xml file path"
!     print "  -r --reprogram\n     Reprogram the network"
!     print "  -b --reprogram_bs\n     Reprogram only the directly-connected mote"
      print "  -d --dissemination\n     Disseminate the image in the external flash to the network"
      print "  -e --erase\n     Erase an image in the external flash"
***************
*** 416,422 ****
          print "Pinging node ..."
          op_inject(s, sys.argv[4], sys.argv[5])
!     elif sys.argv[3] in ["-r", "--reboot"]:
          if op_reprog(s, sys.argv[4]):
              print "Command sent"
      elif sys.argv[3] in ["-d", "--dissemination"]:
          if op_diss(s, sys.argv[4]):
--- 433,442 ----
          print "Pinging node ..."
          op_inject(s, sys.argv[4], sys.argv[5])
!     elif sys.argv[3] in ["-r", "--reprogram"]:
          if op_reprog(s, sys.argv[4]):
              print "Command sent"
+     elif sys.argv[3] in ["-b", "--reprogram_bs"]:
+         if op_reprog_bs(s, sys.argv[4]):
+             print "Command sent"
      elif sys.argv[3] in ["-d", "--dissemination"]:
          if op_diss(s, sys.argv[4]):



More information about the Tinyos-2-commits mailing list