]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tools/tinyos/misc/tos-nwprog
Added support for program images larger than 65k in nwprog.
[tinyos-2.x.git] / tools / tinyos / misc / tos-nwprog
index d8c78a3fe28333c70808ee7e5ba756dafb82ab8f..4d0ef1df8cb6f82ac9a37938529cfdf347a39d2c 100755 (executable)
@@ -51,8 +51,8 @@ DELUGE_IDENT_SIZE   = 128
 
 NWPROG_PORT = 5213
 NWPROG_PKT_SIZE = 64
-NWPROG_REQ_FMT = "!BBH"
-NWPROG_REPLY_FMT = "!BBBBH"
+NWPROG_REQ_FMT = "!BBL"
+NWPROG_REPLY_FMT = "!BBBBL"
 
 ERROR_SUCCESS = 0
 nRetries = 3
@@ -63,7 +63,7 @@ class CommandFailedException:
 def send_command(cmd_str, retries):
     s.sendto(cmd_str, (remote, NWPROG_PORT))
     s.settimeout(3)
-    (real_cmd, real_imgno, real_offset) = struct.unpack(NWPROG_REQ_FMT, cmd_str[0:4])
+    (real_cmd, real_imgno, real_offset) = struct.unpack(NWPROG_REQ_FMT, cmd_str[0:6])
     try:
         data, addr = s.recvfrom(1024)
         # make sure this is the guy we're programming
@@ -95,7 +95,7 @@ def read(imgNum, unused=None):
 
         data = send_command(sreqpkt, 5)
         if data != False:
-            (error, pack, cmd, imgno, offset) = struct.unpack(NWPROG_REPLY_FMT, data[0:6])
+            (error, pack, cmd, imgno, offset) = struct.unpack(NWPROG_REPLY_FMT, data[0:8])
             if offset == pkt_offset:
                 for c in data[6:]:
                     print >>sys.stderr, ord(c)