【问题标题】:Faild to claim interface while developing webusb api开发 webusb api 时声明接口失败
【发布时间】:2017-12-09 10:00:33
【问题描述】:

我正在尝试使用 html 和 javascript 开发一个 webusb api,操作系统是 Ubuntu 16.04。我可以从浏览器连接并打开 USB 设备,但出现错误“无法声明接口 0:设备或资源繁忙 (16)”。请给我一个合适的解决方案。

这是脚本代码, 变种设备;

function setup(device) {
    alert(device.productName+" open");

    return device.open()

    .then(() => device.selectConfiguration(1))
    .then(() => device.claimInterface(0))
    .then(() => this.device_.selectAlternateInterface(1, 0))


}

function connect() {
    if (device == null) {
        navigator.usb.requestDevice({ filters: [{ vendorId : 2352 }] })
        .then(selectedDevice => {
            device = selectedDevice;
            console.log(device);
            return setup(device);
            alert("usb connected");
        })

        .catch(error => { console.log(error); })
    }


}
navigator.usb.getDevices()
.then(devices => {
    if (devices.length > 0) {
        device = devices[0];
        return setup(device);
    }
})
.catch(error => { console.log(error); });

这是我添加的规则文件

SUBSYSTEM=="usb", ATTR{idVendor}=="0930",ATTR{idProduct}=="6544", MODE="0666", GROUP="plugdev"

我是否可以通过将设备与内核分离来做到这一点?怎么可能?

【问题讨论】:

标签: javascript google-chrome ubuntu-16.04 webusb


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    • 2017-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    相关资源
    最近更新 更多