nxt-python を使用して、ラズベリーパイから nxt ブリックに接続しています。
BluetoothおよびUSBライブラリのpython 3.2バージョンとのいくつかの闘争の後、Bluetooth経由で接続してパスキーを要求することができました。さらに苦労した後bluetooth-agent PASSKEY &
、nxtブリックに接続するpythonスクリプトを実行する前に、端末に入力(およびPASSKEYをパスキーに置き換える)できることがわかりました。しかし、今ではエラーがスローされます。USB で接続すると、別のエラーがスローされます。
両方の方法 (USB & BT) とデバッグを有効にした場合に発生するエラーは次のとおりです。
USB: True BT: True Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/nxt/locator.py", line 138, in find_one_brick
if name and info[0].strip('\0') != name:
TypeError: Type str doesn't support the buffer API
Failed to connect to possible brick
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/nxt/locator.py", line 131, in find_one_brick
info = b.get_device_info()
File "/usr/local/lib/python3.2/dist-packages/nxt/brick.py", line 27, in poll
self.sock.send(ogram.bytes())
File "/usr/local/lib/python3.2/dist-packages/nxt/bluesock.py", line 57, in send
l0 = len(data.encode('utf-8')) & 0xFF
AttributeError: 'bytes' object has no attribute 'encode'
Failed to connect to possible brick
No brick was found.
Is the brick turned on?
For more diagnosing use the debug=True argument or
try the 'nxt_test' script located in /bin or ~/.local/bin
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/nxt/locator.py", line 154, in find_one_brick
raise BrickNotFoundError
nxt.locator.BrickNotFoundError
私はPythonを知っているので、ソースコードを編集するだけでおそらくエラーを修正できますが、何かを壊してしまうのではないかと心配しています. 私はそれを編集しようとしました(編集したすべてのファイルのバックアップを保持しています)が、別の別のエラーをスローする前に数行を過ぎます。
編集
Python 2 を使用してインポートしようとすると、次のエラーが表示されます。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nxt/__init__.py", line 15, in <module>
from nxt.locator import find_one_brick, Method
File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 49
if not silent: print("USB module unavailable, not searching there", file=sys.stderr)
^
SyntaxError: invalid syntax