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'.