aboutsummaryrefslogtreecommitdiff
path: root/nxt-python-fantom/nxt/fantomglue.py
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-05-05 12:02:54 +0800
committerTat-Chee Wan (USM)2011-05-05 12:02:54 +0800
commit849bb04045a9c458420e210414b5a4d211cde76d (patch)
tree791914d385a4c2971ef41e454b7c23884daacd13 /nxt-python-fantom/nxt/fantomglue.py
parent667197864959c669690dedd4de835328a5560201 (diff)
Added del method to make sure that nxt object is cleaned up
Diffstat (limited to 'nxt-python-fantom/nxt/fantomglue.py')
-rw-r--r--nxt-python-fantom/nxt/fantomglue.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/nxt-python-fantom/nxt/fantomglue.py b/nxt-python-fantom/nxt/fantomglue.py
index 359427d..a977696 100644
--- a/nxt-python-fantom/nxt/fantomglue.py
+++ b/nxt-python-fantom/nxt/fantomglue.py
@@ -64,7 +64,13 @@ class BluetoothSocket:
def close(self):
if self._sock is not None:
del self._sock
-
+ self._sock = None
+
+ def __del__(self):
+ """Destroy interface."""
+ if self._sock is not None:
+ del self._sock
+
class BluetoothError(IOError):
pass
@@ -127,10 +133,22 @@ class USBSocket:
def recv(self, numbytes):
return self._sock.read( numbytes )
+
+ #def poll_command(self, numbytes):
+ # I'm not sure if this is specific to Direct Command Processing
+ # Or if it refers to any data transmission
+ #print "Bytes Available:", self._sock.bytes_available()
+ #return self._sock.read_buffer( numbytes, 0 )
def close(self):
if self._sock is not None:
del self._sock
+ self._sock = None
+
+ def __del__(self):
+ """Destroy interface."""
+ if self._sock is not None:
+ del self._sock
if __name__ == '__main__':
#get_info = False