aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
diff options
context:
space:
mode:
authorTC Wan2011-01-14 17:12:41 +0800
committerTC Wan2011-01-14 17:12:41 +0800
commitf54ce9032bfb6183351e50416ed398749db20916 (patch)
treeabb8cb11dabca5666dbd5f9c180a2b1352ae265f /AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
parentcc6dfb5609d3b6b5fef576146b334c925c0b80d3 (diff)
parent886f90b0ac34530dabfa41720e40cb82e6b65bc7 (diff)
Merge branch 'master' of ssh://svc.cs.usm.my/~/gitrepo-bare/armdebug
Diffstat (limited to 'AT91SAM7S256/armdebug/Host/nxt-gdb-server.py')
-rwxr-xr-xAT91SAM7S256/armdebug/Host/nxt-gdb-server.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py b/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
index b57a810..b2b2f1c 100755
--- a/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
+++ b/AT91SAM7S256/armdebug/Host/nxt-gdb-server.py
@@ -55,9 +55,9 @@ class NXTGDBServer:
return ''
header, body = data[0:3], data[3:]
command, segment_no, length = struct.unpack ('BBB', header)
- if command != self.debug_command or length != len (body) or segment_no != 0:
- return ''
- return body
+ if command != self.debug_command or length != len (body):
+ return '', segment_no
+ return body, segment_no
def segment (self, data):
"""Split datas in GDB commands and make segments with each command."""
@@ -79,7 +79,19 @@ class NXTGDBServer:
# Look for next one.
end = self.in_buf.find ('#')
return segs
-
+
+ def reassemble (self, sock):
+ msg = ''
+ prev_segno = 0
+ segno = 1 # force initial pass through while loop
+ while (segno != 0):
+ s, segno = self.unpack (sock.recv ())
+ if (segno != 0):
+ assert(segno == (prev_segno + 1)), "segno = %s, prev_segno = %s" % (segno, prev_segno)
+ prev_segno = segno
+ msg.append(s)
+ return msg
+
def run (self):
"""Endless run loop."""
# Create the listening socket.
@@ -113,10 +125,10 @@ class NXTGDBServer:
client = None
# Is there something from NXT brick?
try:
- data = self.unpack (brick.sock.recv ())
- # We don't handle segmented messages yet!
+ data = reassemble(brick.sock)
if data:
client.send (data)
+ data = ''
except usb.USBError as e:
# Some pyusb are buggy, ignore some "errors".
if e.args != ('No error', ):