Javascript 开发webusb api时未能声明接口
我正在尝试使用html和javascript开发一个webusb api,操作系统是Ubuntu 16.04。我可以从浏览器连接并打开usb设备,但出现错误“未能声明接口0:设备或资源繁忙(16)”。请给我一个合适的解决方案 这是脚本代码, 无功装置Javascript 开发webusb api时未能声明接口,javascript,google-chrome,ubuntu-16.04,webusb,Javascript,Google Chrome,Ubuntu 16.04,Webusb,我正在尝试使用html和javascript开发一个webusb api,操作系统是Ubuntu 16.04。我可以从浏览器连接并打开usb设备,但出现错误“未能声明接口0:设备或资源繁忙(16)”。请给我一个合适的解决方案 这是脚本代码, 无功装置 function setup(device) { alert(device.productName+" open"); return device.open() .then(() => device.selectC
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”
我是否可以通过将设备与内核分离来实现这一点?这是怎么可能的?这个问题与“.”是重复的。你能添加你的代码吗?可能重复的