aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-05-04 08:18:57 +0800
committerTat-Chee Wan (USM)2011-05-04 08:18:57 +0800
commitb97df7cade4aef09d7af6433483b6d23858b3f10 (patch)
treeb81b3257bf1c8a328c2e4b8edc6c9db237264bda /AT91SAM7S256/armdebug
parent5da633ada55ba06757fedddda01c34f273375cb7 (diff)
parent05b196d6bf26b0fe70a43607269f88187f595673 (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.py12
-rw-r--r--AT91SAM7S256/armdebug/nxt-python-fantom/nxt/pyusbglue.py2
-rw-r--r--AT91SAM7S256/armdebug/nxt-python-fantom/nxt/usbsock.py4
3 files changed, 13 insertions, 5 deletions
diff --git a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py
index ac125ed..96bcd3c 100644
--- a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py
+++ b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/fantomglue.py
@@ -16,6 +16,8 @@
import pyfantom
+USB_BUFSIZE = 64
+
RFCOMM=11 # lightblue const
FANTOM_BT = RFCOMM # For compatibilty with lightblue
FANTOM_USB = 0
@@ -66,9 +68,12 @@ def _check_brick(arg, value):
def find_devices(lookup_names=False): # parameter is ignored
devicelist = []
for d in pyfantom.NXTIterator(False):
- #name = d.get_name()
- #print "NXT name: ", name
+ addr = d.get_resource_string()
+ print "NXT addr: ", addr
nxt = d.get_nxt()
+ # BUG?: If nxt.get_firware_version() is enabled, d.get_nxt() will throw an exception
+ # Related to Reference Counting for Obj-C Objects?
+ #print " firmware version:", nxt.get_firmware_version()
devicelist.append(nxt)
return devicelist
@@ -90,6 +95,7 @@ class USBSocket:
def __init__(self, device=None):
# We instantiate a NXT object only when we connect if none supplied
+ # 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
@@ -101,7 +107,7 @@ class USBSocket:
def connect(self):
if self._sock is None:
# Port is ignored
- self._sock = pyfantom.NXT(addr)
+ self._sock = pyfantom.NXT(addr) # FIXME: No address!
def send(self, data):
return self._sock.write( data )
diff --git a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/pyusbglue.py b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/pyusbglue.py
index 40f708b..c0f8792 100644
--- a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/pyusbglue.py
+++ b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/pyusbglue.py
@@ -16,6 +16,7 @@
import usb
+USB_BUFSIZE = 64
ID_VENDOR_LEGO = 0x0694
ID_PRODUCT_NXT = 0x0002
@@ -44,7 +45,6 @@ class USBSocket:
self.handle.reset()
if self.debug:
print 'Connected.'
- return Brick(self)
def close(self):
'Use to close the connection.'
diff --git a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/usbsock.py b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/usbsock.py
index 9df7792..aa766a8 100644
--- a/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/usbsock.py
+++ b/AT91SAM7S256/armdebug/nxt-python-fantom/nxt/usbsock.py
@@ -12,6 +12,8 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
+USB_BUFSIZE = 64
+
try:
import fantomglue as usb
except ImportError:
@@ -55,7 +57,7 @@ class USBSock(object):
def recv(self):
'Use to recieve raw data over USB connection ***ADVANCED USERS ONLY***'
- data = self.sock.recv(64)
+ data = self.sock.recv(USB_BUFSIZE)
if self.debug:
print 'Recv:',
print ':'.join('%02x' % (c & 0xFF) for c in data)