WebSerial API on WINDOWS - "DOMException: Failed to open serial port."

Discussão em 'Angular' iniciado por Franklin Rogélio, Dezembro 5, 2024.

  1. I am trying to use the WebSerial API on Windows after it worked fine on macOS with no problem. The device was plugged into a Macbook and no extra action was required. When I connect the device (USB to Serial adapter) to a Windows machine and access my Angular website using Google Chrome, I get this error:


    DOMException: Failed to open serial port.
    ​

    When I access chrome://device-log/ I see this error:


    [USB][ERROR][17:09:20] Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
    ​

    Below is the code that I am using, and an error is displayed when code runs line await this.scale.open({ baudRate: 9600 });.

    const VENDOR_ID = 1027;
    const PRODUCT_ID = 24577;

    ...

    let button = document.getElementById('request-device');
    button.addEventListener('click', async () => {
    try {

    this.scale = await navigator.serial.requestPort({
    filters: [{
    usbProductId: PRODUCT_ID,
    usbVendorId: VENDOR_ID
    }]
    });

    await this.scale.open({ baudRate: 9600 }); //ERROR HAPPENS HERE

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


    There are two similar questions here on for Ubuntu but no answers or solutions were given. (Question 1 and Question 2)

    Continue reading...

Compartilhe esta Página