WICG / serial

Serial ports API for the platform.
https://wicg.github.io/serial/
Other
256 stars 48 forks source link

Provide a user-visible port name in getInfo() #175

Open Hmm466 opened 1 year ago

Hmm466 commented 1 year ago

Usually, when our users use Web serial to control locally, there may be serial devices from the same manufacturer or other trusted devices locally. For a friendly experience, we have to use navigator.serial.getPorts to obtain trusted devices, but Only usbProductId and usbVendorId can be obtained through getInfo, which makes my user unable to choose the device he needs friendly when selecting the target device, even if he uses the Windows Device Manager. If this method is not used, the user needs to pop up a window to select a device every time, which is extremely bad for the user experience. For example, the customer has two arduino devices, but he can't choose. I don't think there is any worse experience than the serial port name or manufacturer returned after getting the information. Is there any worse experience than this? So I want to see if there is a way to get serial port information to improve user experience

reillyeon commented 1 year ago

I'm going to use this issue to track the specific request for providing a "port name" field in getInfo(). This is distinct from the "device ID" proposed in #128. I think both are necessary. The "port name" being a user-visible value that satisfies the user experience concern raised here while a "device ID" would be used internally be applications to track information about ports they have previously connected to. While a "device ID" would be guaranteed to be unique, over time many devices could have the same user-visible "port name".

jessekingf commented 1 year ago

I hope this is something that will be addressed sooner than later. Currently, it is not possible in most cases to select the correct port when using multiple devices. Especially when using Bluetooth SPP or serial-to-USB adapters that report the same hardware IDs (or no hardware IDs).

reillyeon commented 1 year ago

@jessekingf can you clarify whether you mean that it is difficult for the user to select the correct port in the permission prompt presented when requestPort() is called or that it is difficult for the application to select correctly between multiple devices it has permission to access that it receives from getPorts()?

The former is out of scope for this issue and is something to fix at an implementation level (improving how the browser UI works) rather than a specification level.

Hmm466 commented 1 year ago

@jessekingf can you clarify whether you mean that it is difficult for the user to select the correct port in the permission prompt presented when requestPort() is called or that it is difficult for the application to select correctly between multiple devices it has permission to access that it receives from getPorts()?

The former is out of scope for this issue and is something to fix at an implementation level (improving how the browser UI works) rather than a specification level.

I still think that when getting a paired COM device, it should return the COM name, just like Windows Explorer. In this way, when my webpage needs to use more than two COMs and they are from the same manufacturer, it can be used quickly, without requiring the user to choose every time it is used. This is a very bad experience, because some have URL of the commercial form.

jessekingf commented 1 year ago

@jessekingf can you clarify whether you mean that it is difficult for the user to select the correct port in the permission prompt presented when requestPort() is called or that it is difficult for the application to select correctly between multiple devices it has permission to access that it receives from getPorts()?

Difficult for the application to differentiate between already authorized ports returned from getPorts().

yelhouti commented 1 year ago

The same way we are able to do:

const device = (await navigator.usb.getDevices()).find(d => d.serialNumber === ...)

We should have something like:

const port = (await navigator.serial.getPorts()).find(p => p.path === ...)

or something equivalent to select between COM1, COM2...

gbmhunter commented 4 months ago

+1 for this feature! A common use case for embedded development is to have 4 of the same FTDI USB-to-serial cable connected or 4 of the same dev. kit. All of these present the same vendor IDs. Having a user visible "COM2" or "/dev/ttyUSB0" equivalent would help with distinguishing them. Also, as proposed in the other issue, having a unique ID would be great also. This would allow an app to either use the ID directly or let the user associate a "friendly name" with an ID (e.g. "My LED light strip controller").

DogeVenci commented 2 months ago

+1