Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The serial port select popup on linux seem not really useful. #52

Open
vajahath opened this issue Nov 29, 2022 · 9 comments
Open

The serial port select popup on linux seem not really useful. #52

vajahath opened this issue Nov 29, 2022 · 9 comments

Comments

@vajahath
Copy link

vajahath commented Nov 29, 2022

This is how it looks on Ubuntu 22.04.1 (Chrome Version 107.0.5304.121).

Image:

image

Is this the actual expected behaviour?

The list extends from ttyS0 to ttyS31. This list seem not really useful from a user standpoint.

Update: I was expecting something more readable as shown here: https://developer.chrome.com/articles/serial/#:~:text=User%20prompt%20for%20selecting%20a%20BBC%20micro%3Abit

@reillyeon
Copy link
Collaborator

This is a side effect of your system configuration, which appears to be telling Chrome that there are 32 platform serial ports. These ports don't have nice names like USB devices do. On a typical system there would be only a few of these. I don't know why yours has so many.

If you were using the Web Serial API in your own application and were expecting a particular USB device you could filter these out with a usbVendorId filter.

@vajahath
Copy link
Author

Thanks for the explanation. Understood.

Let me record here what I observed with a couple of my friend's machines.

For:

  • mac os - friend's machine - this seem working fine.
  • Ubuntu 22.04 - friend's machine - same as my case - ttySx
  • Ubuntu 20.04 - friend's machine - same as my case - ttySx
  • Fedora - pending
  • Windows - pending

(I'll try to update these details when I get the data. I've requested it.)

Looks like this is not a specific issue of my installation or system configuration. Because I was able to reproduce this on different machines, I think this could be an issue with either ubuntu or chrome.

Since this API is not yet stabilised, I thought I could give some feedback.

If you were using the Web Serial API in your own application and were expecting a particular USB device you could filter these out with a usbVendorId filter.

Yes, I learned about this in mdn. Thanks for pointing out.

A tiny usage feedback of usbVendorId

In my case, when I used the usbVendorId to filter the ports, none of them appeared. The popup list was empty.

May be because the vendor id I provided could be wrong. But I found no way to debug this.

Unlike the WebUSB API, where we get a vendorId with the USBDevice object, WebSerial API doesn't seem to have enough information included in the SerialPort. I also tried to call SerialPort.getInfo() - but got an empty object on my machine.

If there were some details provided with the SerialPort object (like in the USBDevice object), I would be able to at least manually iterate and find the actual usbVendorId associated with each ports - and crosscheck that with my filter.

Not sure if this is an Ubuntu issue, but in Ubuntu, this is what I get.

In short, in my Ubuntu case,

  • I'm unable to use WebSerial because
    • the ttySx is not very readable.
    • the SerialPort or the getInfo() is not giving enough details - so I cannot identify whether the selected port is the right port or not.
    • my usbVendorId filter is not working - and unable to debug
  • I'm unable to use WebUSB because of this issue on SO - https://stackoverflow.com/q/74612160/3370568 (thank you for checking into this)

@reillyeon
Copy link
Collaborator

The ttySx devices aren't USB devices, they represent the serial ports that your system has built-in. The system doesn't give us hardly any information about them, which is why they don't have names and getInfo() returns an empty object.

The reason they all disappear when you specify a usbVendorId filter is that there aren't any USB serial ports on your system, so nothing is available to select.

The device you are trying to access is not a serial device, it is a printer device. As you can see in your SO post the device is only accessible to root and users in the lp group. If you add your current user to that group then you should be able to open the device.

@reillyeon
Copy link
Collaborator

Since this API is not yet stabilised, I thought I could give some feedback.

As a note, this API is stable but feedback is always welcome and can influence future additions to the API.

@vajahath
Copy link
Author

That explanation helped a lot.

The system doesn't give us hardly any information about them, which is why they don't have names and getInfo() returns an empty object.

hmm so there we seem to have a feature parity issue.

@reillyeon
Copy link
Collaborator

It would be nice to figure out why some systems are enumerating so many ports. I would be very surprised if your system had so many UARTs. x86 systems typically have 4 and you'll see a chunk of kernel messages like this on boot as the driver loads:

Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
00:04: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
00:05: ttyS2 at I/O 0x3e8 (irq = 6, base_baud = 115200) is a 16550A
00:06: ttyS3 at I/O 0x2e8 (irq = 7, base_baud = 115200) is a 16550A

Do you see similar messages but counting all the way up to ttyS31?

hmm so there we seem to have a feature parity issue.

I wish the OS gave us enough information to do better here. The Web Serial API supports them because some users may have a device connected to one of them, but most of the time with modern devices you are using USB and so the filtering can hide them.

@vajahath
Copy link
Author

vajahath commented Dec 4, 2022

Right. This is how mine looks like (Ubuntu 22)

Dec  4 16:00:08 vaju-jellifish-3410 kernel: [    0.530713] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled

But I couldn't see any ttySx iterations in the kernel log (like the one you showed).

Clipped:

Dec  4 16:00:08 vaju-jellifish-3410 kernel: [    0.528175] ACPI: button: Power Button [PBTN]
Dec  4 16:00:08 vaju-jellifish-3410 kernel: [    0.528293] smpboot: Estimated ratio of average max frequency by base frequency (times 1024): 1914
Dec  4 16:00:08 vaju-jellifish-3410 kernel: [    0.530713] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled
Dec  4 16:00:08 vaju-jellifish-3410 kernel: [    0.532101] serial 0000:00:13.0: enabling device (0000 -> 0002)
Dec  4 16:00:08 vaju-jellifish-3410 kernel: [    0.533013] hpet_acpi_add: no address or irqs in _CRS
Dec  4 16:00:08 vaju-jellifish-3410 kernel: [    0.533055] Linux agpgart interface v0.103

@reillyeon
Copy link
Collaborator

Skimming the Linux 8250 serial port driver it looks like it might be configuring ports based on the maximum specified at compile time. I don't know enough about the hardware to know if that's the best it can do and if detecting ports at boot is not possible.

@ldijkman
Copy link

not a problem for me on linux mint
just select usb

https://ldijkman.github.io/async-esp-fs-webserver/WebSerialMonitor.html
and another use of webserial
https://ldijkman.github.io/async-esp-fs-webserver/

Screenshot from 2024-02-18 05-58-16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants