cython hidapi写错误

时间:2017-04-25 16:50:12

标签: python usb cython hidapi

我正在尝试写一个连接到raspberry pi 3的USB设备。

错误:

  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.

这段代码有什么问题?根据库中的文档,它接受任何整数列表。

我用它作为参考:https://github.com/trezor/cython-hidapi/blob/master/try.py

1 个答案:

答案 0 :(得分:2)

列表中缺少逗号分隔。

列表应以,(逗号)分隔,

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

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