aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/Host
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-01-18 07:35:26 +0800
committerTat-Chee Wan (USM)2011-01-18 07:35:26 +0800
commit239dac94dc5debc30c194fb878dce8d804757007 (patch)
treefe44e033ce573dafa5d9ce175278c25d89a9dd3a /AT91SAM7S256/armdebug/Host
parentcc366273833a036d4650a0f06aaa2e6342a3a56c (diff)
parent3ce940a3517e8b1752b523db0dc6daaf5c2831e0 (diff)
Merge branch 'master' of ssh://svc.cs.usm.my/~/gitrepo-bare/armdebug
Diffstat (limited to 'AT91SAM7S256/armdebug/Host')
-rwxr-xr-xAT91SAM7S256/armdebug/Host/nxt-gdb-server.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py b/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
index 544b89c..f59de1a 100755
--- a/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
+++ b/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
@@ -52,6 +52,8 @@ class NXTGDBServer:
def unpack (self, data):
"""Return unpacked data from NXT."""
# May be improved, for now, check command and announced length.
+ if len (data) == 0:
+ return '', 0 # No message, exit
if len (data) < 3:
return '', NXT_RECV_ERR
header, body = data[0:3], data[3:]
@@ -84,12 +86,20 @@ class NXTGDBServer:
def reassemble (self, sock):
msg = ''
prev_segno = 0
- segno = NXT_RECV_ERR # force initial pass through while loop
+ segno = NXT_RECV_ERR # force initial pass through while loop
while segno != 0:
try:
s, segno = self.unpack (sock.recv ())
+ if len (s) == 0:
+ if segno == 0 && prev_segno == 0:
+ return '' # No message pending
+ else
+ segno = NXT_RECV_ERR # Keep waiting for segments
+ # Ignore error packets
if segno >= 0:
- assert segno == (prev_segno + 1), "segno = %s, prev_segno = %s" % (segno, prev_segno)
+ # Check segno, if non-zero it must be monotonically increasing from 1, otherwise 0
+ if segno > 0:
+ assert segno == (prev_segno + 1), "segno = %s, prev_segno = %s" % (segno, prev_segno)
prev_segno = segno
msg.append(s)
except usb.USBError as e: