我使用nxt连接我的raspberry pi的nxt砖。
在与python3.2版本的蓝牙和usb库进行了一番斗争之后,我需要设法让它通过蓝牙连接并请求一个密码。经过更多的挣扎之后,我发现在运行与nxt块连接的python脚本之前,我可以在终端中键入bluetooth-agent PASSKEY & (并用PASSKEY替换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发布于 2016-07-05 01:37:36
我下载了v2.2.2稳定版本,而不是克隆主提交,它在python2下运行良好。可惜的是,它不是python3。
https://stackoverflow.com/questions/38191619
复制相似问题