问题
I'm trying to access a Voyager 1450g barcode scanner that is connected via USB, but navigator.usb.requestDevices() doesn't see this device.
let button = document.getElementById('request-device');
button.addEventListener('click', async () => {
let device;
try {
device = await navigator.usb.requestDevice({ filters: [{}]});
} catch (err) {
// No device was selected.
console.log('Error:', err);
}
I will be grateful for any ideas.
回答1:
I have a Honeywell Voyagar 1202g barcode scanner that I managed to get working with Mac and Windows.
First you will need to change the barcode scanners interface to CDC-ACM, either by using EZConfig (Honeywell software) or by scanning a barcode that you can find on their website.
Steps to get it working on Windows:
- Install Zadig
- Install HSM USB Serial Driver Package
- Find your device in Windows settings and update USB Composite Device driver (Let me pick from a list of drivers, uncheck compitable drivers) to use Honeywell->WinFlash Intermec Device (without this step Zadig could not find the correct interface).
- Using Zadig you should now see your device, update driver to libusbk
- Restart PC (important)
Code:
const decoder = new TextDecoder();
const startDevice = async () => {
try {
// you should be able to discover your PRODUCT_ID and VENDOR_ID from
// chrome://device-log
const device = await navigator.usb.requestDevice({
filters: {
productId: PRODUCT_ID,
vendorId: VENDOR_ID
}
});
// log device data to see available configurations and interfaces
await device.open();
// only 1 configuration was available for me
await device.selectConfiguration(1);
// interface 1 was bulk transfer
await device.claimInterface(1);
readLoop(device);
} catch (error) {
console.error(error);
}
}
const readLoop = async (device) => {
try {
const result = await device.transferIn(1, 64);
// this is your incoming data
const data = decoder.decode(result.data).trim();
readLoop(device);
} catch (error) {
console.error(error);
}
}
回答2:
My guess is that the virtual serial port driver (that mounts it as COM3) has captured the device. Maybe uninstall the driver and try again?
来源:https://stackoverflow.com/questions/50373111/google-chrome-webusb-api-requestdevices-doesnt-see-barcode-scanner-voyager-14