简体   繁体   中英

Web Serial API - Uncaught (in promise) DOMException: Failed to open serial port / required member baudRate is undefined

The code below works on my Xubuntu machine, but now I'm on Kubuntu and it isn't working anymore - it won't open the port.

The Arduino IDE works fine (can write code to the board) and I'm able to select the device (Arduino Uno) in Chrome, but the code will stop when I try to open the port: Uncaught (in promise) DOMException: Failed to open serial port or required member baudRate is undefined will come up.

const filters = [
  // Filter on devices with the Arduino Uno USB Vendor/Product IDs.
  { usbVendorId: 0x2341, usbProductId: 0x0043 },
  { usbVendorId: 0x2341, usbProductId: 0x0001 },
];

  async function getPortAndStartReading() {
    if (!portFound) {
      const port = await navigator.serial.requestPort({ filters });
      await port.open({ baudRate: 9600 }) //problem here
      reader = port.readable.getReader();
      outputStream = port.writable
      readLoop();
      if (port) {
          connectionToPortSuccessfulMessage = 'Connection successful'
          setPortFound(true)
      }
    }
  }

I've tried changing the permissions on the serial port by following this , so now if I run groups user I get user : user adm dialout cdrom sudo dip plugdev lpadmin lxd sambashare , but it still won't work.

I've also checked chrome://device-log to see if I could find any errors but all I get is info about (physically) adding or removing a USB device.

I believe the member name has recently been changed from 'baudrate' to 'baudRate'. At least in my case changing from 'baudrate' (which used to work) to 'baudRate' fixed it for me. Could it perhaps be Kubuntu is using an older chrome version that expects 'baudrate'.

I am also having the same issue. I have an online IDE for CircuitPython:

https://github.com/Mr-Coxall/CircuitPython-IDE

ide.mths.ca

It was working fine and has recently stopped with the same error you are getting. Not sure what has changed recently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM