下面的代码可以在我的 Xubuntu 机器上运行,但现在我在 Kubuntu 上,它不再工作了 - 它不会打开端口。
Arduino IDE 工作正常(可以向开发板写入代码),我可以在 Chrome 中选择设备 (Arduino Uno),但当我尝试打开端口时,代码将停止:Uncaught (in promise) DOMException: Failed to open serial port或required member baudRate is undefined将出现。
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 …Run Code Online (Sandbox Code Playgroud)