Google Chrome WebUSB API requestDevices() doesn't see barcode scanner Voyager 1450g

不打扰是莪最后的温柔 提交于 2020-01-06 04:34:11

问题


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:

  1. Install Zadig
  2. Install HSM USB Serial Driver Package
  3. 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).
  4. Using Zadig you should now see your device, update driver to libusbk
  5. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!