From 0bf5f4efbea18e4402814f8cacd79967a4257e50 Mon Sep 17 00:00:00 2001 From: TC Wan Date: Wed, 27 Apr 2011 15:21:17 +0800 Subject: wip pyfantom support Some minor cleanups for pyfantom support --- nxt-python-fantom/nxt/fantomglue.py | 4 ++++ nxt-python-fantom/nxt/pyusbglue.py | 4 ++-- nxt-python-fantom/nxt/usbsock.py | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'nxt-python-fantom/nxt') diff --git a/nxt-python-fantom/nxt/fantomglue.py b/nxt-python-fantom/nxt/fantomglue.py index 89c08b2..5e85e03 100644 --- a/nxt-python-fantom/nxt/fantomglue.py +++ b/nxt-python-fantom/nxt/fantomglue.py @@ -91,6 +91,10 @@ class USBSocket: self._sock = device self.debug = False + def device_name(self): + devinfo = self._sock.deviceinfo() + return devinfo.name + def connect(self): addr, port = addrport if self._sock is None: diff --git a/nxt-python-fantom/nxt/pyusbglue.py b/nxt-python-fantom/nxt/pyusbglue.py index 2d64d24..40f708b 100644 --- a/nxt-python-fantom/nxt/pyusbglue.py +++ b/nxt-python-fantom/nxt/pyusbglue.py @@ -28,8 +28,8 @@ class USBSocket: self.handle = None self.debug = False - def __str__(self): - return 'USB (%s)' % (self.device.filename) + def device_name(self): + return self.device.filename def connect(self): 'Use to connect to NXT.' diff --git a/nxt-python-fantom/nxt/usbsock.py b/nxt-python-fantom/nxt/usbsock.py index 3e2ed58..78c21ab 100644 --- a/nxt-python-fantom/nxt/usbsock.py +++ b/nxt-python-fantom/nxt/usbsock.py @@ -29,8 +29,7 @@ class USBSock(object): self.debug = False def __str__(self): - # FIXME: This breaks encapsulation - return 'USB (%s)' % (self.sock.filename) + return 'USB (%s)' % (self.sock.device_name()) def connect(self): 'Use to connect to NXT.' -- cgit v1.2.3