最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get name of connected device in Web Serial API on Chrome - Stack Overflow

programmeradmin3浏览0评论

As per Chrome Platform Status Web Serial API is now state of shipping since Chrome V89.

I work on a Universal Serial Communication App, which allows to connect to a user selected serial port. After a let port = await navigator.serial.requestPort() the user selects a port from the list presented by chrome. This list contains names for the devices. Connecting the chosen port with port.open(conSettings) is no problem.

But how can i get the NAME of the selected port/device (from the shown list) using the Web Serial API? This is needed to show a status like "connected to ...". Without this it is confusing if you have multiple tabs with different ports open.

As per Chrome Platform Status Web Serial API is now state of shipping since Chrome V89.

I work on a Universal Serial Communication App, which allows to connect to a user selected serial port. After a let port = await navigator.serial.requestPort() the user selects a port from the list presented by chrome. This list contains names for the devices. Connecting the chosen port with port.open(conSettings) is no problem.

But how can i get the NAME of the selected port/device (from the shown list) using the Web Serial API? This is needed to show a status like "connected to ...". Without this it is confusing if you have multiple tabs with different ports open.

Share Improve this question edited Jun 30, 2021 at 12:30 Lutz asked Jun 30, 2021 at 12:16 LutzLutz 8701 gold badge10 silver badges19 bronze badges 2
  • 1 I don't think you can, at this point. SerialPort.getInfo() returns usbProductId and usbVendorId for USB ports and nothing (on my Win10 box) for built-in ports. Maybe this data will be available in the future: github./WICG/serial/issues/128#issuement-795870509 – 001 Commented Jun 30, 2021 at 13:19
  • thanks @Johnny Mopp. This is the same post, which i stumbled upon in the last minutes ... – Lutz Commented Jun 30, 2021 at 13:23
Add a ment  | 

1 Answer 1

Reset to default 5

I found this post, from March, the 10th 2021, from reillyeon (which is a Google chromium software engineer for usb and serial). He says it is planed to add an ID to the return of getInfo(), which can be used to remember and reconnect later to a still used device.

At the end of this other post he writes, he plans to "introduce a random identifier", instead of "USB product name or serial number strings", because "concerns about fingerprinting".

So it looks like, at this time there is nothing and it is also not planed to return a device name. But when this would be implemented, it would be possible to save this ID in bination with a user supplied name for the device.

My question anyhow: Is fingerpriting a problem, when the user was still requested and has allowed the access to the device?

发布评论

评论列表(0)

  1. 暂无评论