chrome.hid.send不发送数据包

时间:2016-02-05 23:01:23

标签: google-chrome usb chromium hid

我正在开发一个需要连接到自定义HID设备的Chrome应用程序。我能够从设备接收数据。 我对hid和usb总线有写权限。但是设备没有收到任何数据 我成功地通过hidapi在一个单独的程序中发送数据。 您能否建议任何方法来检查chrome.hid.send是否正常工作? 操作系统:Arch Linux
Chrome版本:46.0​​.2490.22 beta(64位)

1 个答案:

答案 0 :(得分:1)

以下代码段似乎对我有用:(取自chrome-app-samples的HID示例应用程序)

    function sendHid(){
        var bytes = new Uint8Array(63);
        bytes[0] = 0x01;//to send 0x01 to HID device

        chrome.hid.send(connectionId,0,bytes.buffer,function(){
        if (chrome.runtime.lastError) {
            console.log(chrome.runtime.lastError.message);
            return;
           }
        else {
            console.log("Sent!");
            }
        });
       }
相关问题