Skip to content

Commit 33702a5

Browse files
author
marcusw
committed
Tag for v1.1.2
1 parent 218f144 commit 33702a5

File tree

8 files changed

+84
-110
lines changed

8 files changed

+84
-110
lines changed

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
include docs/*.html *.url *.css *.txt
2-
include README.txt LICENSE.txt
2+
include LICENSE
3+
include examples/*.py

docs/nxt_python.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ <h2>Requirements</h2>
5454
</li>
5555
</ul>
5656
<h2>Download</h2>
57+
<ul>
58+
<li>Version 1.1.2<br/>
59+
&mdash;Fixed US sensor when using a USB connection.
60+
<ul>
61+
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.2.zip'>nxt-python-1.1.2.zip</a>
62+
source ZIP archive</li>
63+
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.2.win32.exe'>nxt-python-1.1.2.win32.exe</a>
64+
source ZIP archive</li>
65+
<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>
66+
source ZIP archive</li>
67+
</ul>
68+
</li>
69+
</ul>
70+
<ul>
71+
<li>Version 1.1.1<br/>
72+
&mdash;Fixed missing examples directory problem.
73+
<ul>
74+
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.1.zip'>nxt-python-1.1.1.zip</a>
75+
source ZIP archive</li>
76+
<li><a href='http://NXT-Python.googlecode.com/files/nxt-python-1.1.1.win32.exe'>nxt-python-1.1.1.win32.exe</a>
77+
source ZIP archive</li>
78+
<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>
79+
source ZIP archive</li>
80+
</ul>
81+
</li>
82+
</ul>
5783
<ul>
5884
<li>Version 1.1<br/>
5985
&mdash;New motor functions, namely run() and stop().<br/>

nxt/bluesock.py

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,64 @@
1212
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
# GNU General Public License for more details.
1414

15-
try:
16-
import bluetooth
17-
except ImportError:
18-
import lightblueglue as bluetooth
15+
import bluetooth
1916
import os
20-
from .brick import Brick
17+
from nxt.brick import Brick
2118

2219
class BlueSock(object):
2320

24-
bsize = 118 # Bluetooth socket block size
25-
PORT = 1 # Standard NXT rfcomm port
21+
bsize = 118 # Bluetooth socket block size
22+
PORT = 1 # Standard NXT rfcomm port
2623

27-
def __init__(self, host):
28-
self.host = host
29-
self.sock = None
30-
self.debug = False
24+
def __init__(self, host):
25+
self.host = host
26+
self.sock = None
27+
self.debug = False
3128

32-
def __str__(self):
33-
return 'Bluetooth (%s)' % self.host
29+
def __str__(self):
30+
return 'Bluetooth (%s)' % self.host
3431

35-
def connect(self):
36-
if self.debug:
37-
print 'Connecting via Bluetooth...'
38-
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
39-
sock.connect((self.host, BlueSock.PORT))
40-
self.sock = sock
41-
if self.debug:
42-
print 'Connected.'
43-
return Brick(self)
32+
def connect(self):
33+
if self.debug:
34+
print 'Connecting via Bluetooth...'
35+
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
36+
sock.connect((self.host, BlueSock.PORT))
37+
self.sock = sock
38+
if self.debug:
39+
print 'Connected.'
40+
return Brick(self)
4441

45-
def close(self):
46-
if self.debug:
47-
print 'Closing Bluetooth connection...'
48-
self.sock.close()
49-
if self.debug:
50-
print 'Bluetooth connection closed.'
42+
def close(self):
43+
if self.debug:
44+
print 'Closing Bluetooth connection...'
45+
self.sock.close()
46+
if self.debug:
47+
print 'Bluetooth connection closed.'
5148

52-
def send(self, data):
53-
if self.debug:
54-
print 'Send:',
55-
print ':'.join('%02x' % ord(c) for c in data)
56-
l0 = len(data) & 0xFF
57-
l1 = (len(data) >> 8) & 0xFF
58-
d = chr(l0) + chr(l1) + data
59-
self.sock.send(d)
49+
def send(self, data):
50+
if self.debug:
51+
print 'Send:',
52+
print ':'.join('%02x' % ord(c) for c in data)
53+
l0 = len(data) & 0xFF
54+
l1 = (len(data) >> 8) & 0xFF
55+
d = chr(l0) + chr(l1) + data
56+
self.sock.send(d)
6057

61-
def recv(self):
62-
data = self.sock.recv(2)
63-
l0 = ord(data[0])
64-
l1 = ord(data[1])
65-
plen = l0 + (l1 << 8)
66-
data = self.sock.recv(plen)
67-
if self.debug:
68-
print 'Recv:',
69-
print ':'.join('%02x' % ord(c) for c in data)
70-
return data
58+
def recv(self):
59+
data = self.sock.recv(2)
60+
l0 = ord(data[0])
61+
l1 = ord(data[1])
62+
plen = l0 + (l1 << 8)
63+
data = self.sock.recv(plen)
64+
if self.debug:
65+
print 'Recv:',
66+
print ':'.join('%02x' % ord(c) for c in data)
67+
return data
7168

7269
def _check_brick(arg, value):
73-
return arg is None or arg == value
70+
return arg is None or arg == value
7471

7572
def find_bricks(host=None, name=None):
76-
for h, n in bluetooth.discover_devices(lookup_names=True):
77-
if _check_brick(host, h) and _check_brick(name, n):
78-
yield BlueSock(h)
73+
for h, n in bluetooth.discover_devices(lookup_names=True):
74+
if _check_brick(host, h) and _check_brick(name, n):
75+
yield BlueSock(h)

nxt/direct.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# GNU General Public License for more details.
1414

1515
'Use for direct communication with the NXT ***EXTREMELY ADVANCED USERS ONLY***'
16+
import time
1617

1718
def _create(opcode):
1819
'Create a simple direct telegram'
@@ -152,6 +153,7 @@ def _parse_ls_get_status(tgram):
152153

153154
def ls_write(opcode, port, tx_data, rx_bytes):
154155
'Write a low-speed command to a sensor (ultrasonic)'
156+
time.sleep(0.005)
155157
tgram = _create(opcode)
156158
tgram.add_u8(port)
157159
tgram.add_u8(len(tx_data))

nxt/lightblueglue.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

nxt/locator.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# GNU General Public License for more details.
1414

1515
class BrickNotFoundError(Exception):
16-
pass
17-
16+
pass
17+
1818
class NoBackendError(Exception):
1919
pass
2020

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

3535
try:
36-
import bluesock
36+
from bluetooth import BluetoothError
3737
try:
38+
import bluesock
3839
socks = bluesock.find_bricks(host, name)
3940
for s in socks:
4041
yield s
41-
except (bluesock.bluetooth.BluetoothError, IOError):
42+
except BluetoothError:
4243
pass
4344
except ImportError:
4445
import sys

nxt/sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def __init__(self, brick, port):
255255
sleep(0.1) # Give I2C time to initialize
256256

257257
def get_sample(self):
258-
'Function to get data from ultrasonic sensors, synonmous to self.get_sample()'
258+
'Function to get data from ultrasonic sensors'
259259
self.set_command_state(CommandState.SINGLE_SHOT)
260260
return self.get_measurement_byte_0()
261261

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='nxt-python',
11-
version='1.1',
11+
version='1.1.2',
1212
author='Douglas Lau, Marcus Wanner',
1313
1414
description='LEGO Mindstorms NXT Control Package',

0 commit comments

Comments
 (0)