2017-04-25 127 views
-2

我正在嘗試寫入連接到安裝了raspbian的樹莓派3的USB設備。cython hidapi寫入錯誤

錯誤:

File "<stdin>", line 1 
    h.write([81 80 73 71 83 183 169 13]) 
       ^
SyntaxError: invalid syntax 

代碼

#!/usr/bin/python 
import hid 

h = hid.device() 
h.open(0x0665, 0x5161) 
h.set_nonblocking(1) // Returns 0 
h.write([0, 63, 35, 35] + [0] * 61) // Returns -1 

h.write([81 80 73 71 83 183 169 13]) //Throws error above. 

哪些錯誤與此代碼?根據庫中的文檔,它接受任何整數列表。

我用這作爲ref:https://github.com/trezor/cython-hidapi/blob/master/try.py

回答

1

缺少在列表逗號分開。

列表應該是,(逗號)隔開,

變化h.write([81 80 73 71 83 183 169 13])

h.write([81, 80, 73, 71, 83, 183, 169, 13])