使用 NODE.js/electron。我似乎无法让 WinUSB 正常运行。操作系统是 Windows10,我已经使用 Zadig 将 WinUSB 驱动器安装到 USB 设备,但是当我 打开/调用设备。
const initDevice = async () => {
const filters = [
{vendorId: 0x0403, productId: 0xCC4D},
];
navigator.usb.requestDevice({filters: filters})
.then(usbDevice => {
console.log("Product name: " + usbDevice.productName);
})
.catch(e => {
console.log("There is no device. " + e);
});
await device.open();
const [ configuration ] = device.configurations
if (device.configuration === null) {
await device.selectConfiguration(configuration.configurationValue)
}
await device.claimInterface(configuration.interfaces[0].interfaceNumber)
await device.selectAlternateInterface(configuration.interfaces[0].interfaceNumber, 0)
return device
}