summaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-05-06 13:05:52 +0800
committerTat-Chee Wan (USM)2011-05-06 13:05:52 +0800
commit92beb2ec422a54b2cc5a983933b4a95edabc1ca7 (patch)
treec0681b9572a151bb1c924b07f34dabca86cd34c6 /AT91SAM7S256/armdebug
parent95844a4c56675f5130893ef0c52caa58567cb352 (diff)
parent31046a5e897f5f1349223fdfd030e768e54dbfc0 (diff)
Merge branch 'master' of ssh://svc.cs.usm.my/~/gitrepo-bare/armdebug
Diffstat (limited to 'AT91SAM7S256/armdebug')
-rw-r--r--AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py
index 16d9608..4ba57a7 100644
--- a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py
+++ b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py
@@ -41,6 +41,7 @@ class BluetoothSocket:
# We instantiate a NXT object only when we connect if none supplied
self._sock = _sock
self._proto = proto
+ self.debug = True
def __str__(self):
return 'FantomGlue BT (%s)' % self.device_name()
@@ -63,16 +64,18 @@ class BluetoothSocket:
def close(self):
if self._sock is not None:
- del self._sock
+ self._sock.close()
self._sock = None
- def __del__(self):
- """Destroy interface."""
- if self._sock is not None:
- del self._sock
- print "NXT object deleted"
- else:
- print "No NXT Object when calling __del__ for BluetoothSocket"
+ #def __del__(self):
+ # """Destroy interface."""
+ # if self._sock is not None:
+ # del self._sock
+ # if self.debug:
+ # print "NXT object deleted"
+ # else:
+ # if self.debug:
+ # print "No NXT Object when calling __del__ for BluetoothSocket"
class BluetoothError(IOError):
pass
@@ -112,7 +115,7 @@ class USBSocket:
# FIXME: The addr is not passed in, so we can't actually create a NXT object later
#self.device = device
self._sock = device
- self.debug = False
+ self.debug = True
def __str__(self):
return 'FantomGlue USB (%s)' % self.device_name()
@@ -145,16 +148,18 @@ class USBSocket:
def close(self):
if self._sock is not None:
- del self._sock
+ self._sock.close()
self._sock = None
- def __del__(self):
- """Destroy interface."""
- if self._sock is not None:
- del self._sock
- print "NXT object deleted"
- else:
- print "No NXT Object when calling __del__ for USBSocket"
+ #def __del__(self):
+ # """Destroy interface."""
+ # if self._sock is not None:
+ # del self._sock
+ # if self.debug:
+ # print "NXT object deleted"
+ # else:
+ # if self.debug:
+ # print "No NXT Object when calling __del__ for USBSocket"
if __name__ == '__main__':
#get_info = False
@@ -168,6 +173,7 @@ if __name__ == '__main__':
print " resource string:", rs
if write_read:
nxt = USBSocket(i)
+ nxt.connect()
import struct
# Write VERSION SYS_CMD.
# Query:
@@ -198,4 +204,5 @@ if __name__ == '__main__':
#rep = nxt.recv(USB_BUFSIZE)
#rep = nxt.recv(7)
#print "read", struct.unpack('%dB' % len(rep), rep)
+ nxt.close()
del nxt