Skip to content

Commit

Permalink
Tag for v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusw committed Jun 7, 2010
1 parent 218f144 commit 33702a5
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 110 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include docs/*.html *.url *.css *.txt
include README.txt LICENSE.txt
include LICENSE
include examples/*.py
26 changes: 26 additions & 0 deletions docs/nxt_python.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ <h2>Requirements</h2>
</li>
</ul>
<h2>Download</h2>
<ul>
<li>Version 1.1.2<br/>
&mdash;Fixed US sensor when using a USB connection.
<ul>
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.2.zip'>nxt-python-1.1.2.zip</a>
source ZIP archive</li>
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.2.win32.exe'>nxt-python-1.1.2.win32.exe</a>
source ZIP archive</li>
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.2.win-amd64.exe'>nxt-python-1.1.2.win-amd64.exe</a>
source ZIP archive</li>
</ul>
</li>
</ul>
<ul>
<li>Version 1.1.1<br/>
&mdash;Fixed missing examples directory problem.
<ul>
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.1.zip'>nxt-python-1.1.1.zip</a>
source ZIP archive</li>
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.1.win32.exe'>nxt-python-1.1.1.win32.exe</a>
source ZIP archive</li>
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.1.win-amd64.exe'>nxt-python-1.1.1.win-amd64.exe</a>
source ZIP archive</li>
</ul>
</li>
</ul>
<ul>
<li>Version 1.1<br/>
&mdash;New motor functions, namely run() and stop().<br/>
Expand Down
97 changes: 47 additions & 50 deletions nxt/bluesock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,64 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

try:
import bluetooth
except ImportError:
import lightblueglue as bluetooth
import bluetooth
import os
from .brick import Brick
from nxt.brick import Brick

class BlueSock(object):

bsize = 118 # Bluetooth socket block size
PORT = 1 # Standard NXT rfcomm port
bsize = 118 # Bluetooth socket block size
PORT = 1 # Standard NXT rfcomm port

def __init__(self, host):
self.host = host
self.sock = None
self.debug = False
def __init__(self, host):
self.host = host
self.sock = None
self.debug = False

def __str__(self):
return 'Bluetooth (%s)' % self.host
def __str__(self):
return 'Bluetooth (%s)' % self.host

def connect(self):
if self.debug:
print 'Connecting via Bluetooth...'
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((self.host, BlueSock.PORT))
self.sock = sock
if self.debug:
print 'Connected.'
return Brick(self)
def connect(self):
if self.debug:
print 'Connecting via Bluetooth...'
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((self.host, BlueSock.PORT))
self.sock = sock
if self.debug:
print 'Connected.'
return Brick(self)

def close(self):
if self.debug:
print 'Closing Bluetooth connection...'
self.sock.close()
if self.debug:
print 'Bluetooth connection closed.'
def close(self):
if self.debug:
print 'Closing Bluetooth connection...'
self.sock.close()
if self.debug:
print 'Bluetooth connection closed.'

def send(self, data):
if self.debug:
print 'Send:',
print ':'.join('%02x' % ord(c) for c in data)
l0 = len(data) & 0xFF
l1 = (len(data) >> 8) & 0xFF
d = chr(l0) + chr(l1) + data
self.sock.send(d)
def send(self, data):
if self.debug:
print 'Send:',
print ':'.join('%02x' % ord(c) for c in data)
l0 = len(data) & 0xFF
l1 = (len(data) >> 8) & 0xFF
d = chr(l0) + chr(l1) + data
self.sock.send(d)

def recv(self):
data = self.sock.recv(2)
l0 = ord(data[0])
l1 = ord(data[1])
plen = l0 + (l1 << 8)
data = self.sock.recv(plen)
if self.debug:
print 'Recv:',
print ':'.join('%02x' % ord(c) for c in data)
return data
def recv(self):
data = self.sock.recv(2)
l0 = ord(data[0])
l1 = ord(data[1])
plen = l0 + (l1 << 8)
data = self.sock.recv(plen)
if self.debug:
print 'Recv:',
print ':'.join('%02x' % ord(c) for c in data)
return data

def _check_brick(arg, value):
return arg is None or arg == value
return arg is None or arg == value

def find_bricks(host=None, name=None):
for h, n in bluetooth.discover_devices(lookup_names=True):
if _check_brick(host, h) and _check_brick(name, n):
yield BlueSock(h)
for h, n in bluetooth.discover_devices(lookup_names=True):
if _check_brick(host, h) and _check_brick(name, n):
yield BlueSock(h)
2 changes: 2 additions & 0 deletions nxt/direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# GNU General Public License for more details.

'Use for direct communication with the NXT ***EXTREMELY ADVANCED USERS ONLY***'
import time

def _create(opcode):
'Create a simple direct telegram'
Expand Down Expand Up @@ -152,6 +153,7 @@ def _parse_ls_get_status(tgram):

def ls_write(opcode, port, tx_data, rx_bytes):
'Write a low-speed command to a sensor (ultrasonic)'
time.sleep(0.005)
tgram = _create(opcode)
tgram.add_u8(port)
tgram.add_u8(len(tx_data))
Expand Down
53 changes: 0 additions & 53 deletions nxt/lightblueglue.py

This file was deleted.

9 changes: 5 additions & 4 deletions nxt/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# GNU General Public License for more details.

class BrickNotFoundError(Exception):
pass
pass
class NoBackendError(Exception):
pass

Expand All @@ -33,12 +33,13 @@ def find_bricks(host=None, name=None):
print >>sys.stderr, "USB unavailable, not searching there"

try:
import bluesock
from bluetooth import BluetoothError
try:
import bluesock
socks = bluesock.find_bricks(host, name)
for s in socks:
yield s
except (bluesock.bluetooth.BluetoothError, IOError):
except BluetoothError:
pass
except ImportError:
import sys
Expand Down
2 changes: 1 addition & 1 deletion nxt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def __init__(self, brick, port):
sleep(0.1) # Give I2C time to initialize

def get_sample(self):
'Function to get data from ultrasonic sensors, synonmous to self.get_sample()'
'Function to get data from ultrasonic sensors'
self.set_command_state(CommandState.SINGLE_SHOT)
return self.get_measurement_byte_0()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='nxt-python',
version='1.1',
version='1.1.2',
author='Douglas Lau, Marcus Wanner',
author_email='[email protected], [email protected]',
description='LEGO Mindstorms NXT Control Package',
Expand Down

0 comments on commit 33702a5

Please sign in to comment.