2016-07-04 120 views
1

我正在使用nxt-python連接到我的樹莓派的nxt磚。連接到nxt磚時出錯

經過與3.2版本的藍牙和USB庫的一些鬥爭,它需要我設法讓它通過藍牙連接,並要求密碼。經過一番努力之後,我發現在運行與nxt磚塊連接的python腳本之前,我可以在終端中輸入bluetooth-agent 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 

,因爲我知道蟒蛇我可以通過編輯源代碼可能修復錯誤,但我affraid我會打破一些東西。我試過編輯它(保留我編輯的每個文件的備份),然後在拋出另一個不同的錯誤之前經過幾行。

編輯

當我嘗試使用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 

回答

1

我已經下載了V2.2.2穩定,而不是克隆主提交和運行在python2下很好。太糟糕了,它不是python3。