【问题标题】:WebSerial API on WINDOWS - "DOMException: Failed to open serial port."WINDOWS 上的 WebSerial API - “DOMException:无法打开串行端口。”
【发布时间】:2021-07-29 16:38:15
【问题描述】:

我正在尝试在 Windows 上使用 WebSerial API,因为它在 macOS 上运行良好且没有问题。该设备已插入 Macbook,无需额外操作。当我将设备(USB 到串行适配器)连接到 Windows 机器并使用 Google Chrome 访问我的 Angular 网站时,我收到此错误:

DOMException: 打开串口失败。

当我访问chrome://device-log/ 时,我看到了这个错误:

[USB][ERROR][17:09:20] 无法从节点连接读取描述符: 连接到系统的设备不工作。 (0x1F)

下面是我正在使用的代码,当代码运行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)
      }
    });
  }

这里有两个关于 Ubuntu 的类似问题,但没有给出答案或解决方案。 (Question 1Question 2

【问题讨论】:

    标签: angular windows google-chrome serial-port usbserial


    【解决方案1】:

    这是驱动程序问题。

    大多数旧型号的 USB 转串口适配器在 Windows 10 上都存在问题。在尝试了几个驱动程序后,我发现 this one 解决了我的问题。

    它以我不懂的语言链接到 Youtube 视频。但是,这些步骤很容易遵循。下载驱动并按照步骤操作后,就可以正常使用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-30
      • 2018-10-02
      • 2011-04-26
      • 2020-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多