0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Web Serial API の使い方 (port の絞り込み)

Last updated at Posted at 2022-10-02

こちらのサンプルを改造して port の絞り込みをします。
Web Serial API の使い方

image.png

Vendor ID の調べ方

lsusb

$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 8087:0029 Intel Corp. AX200 Bluetooth
Bus 001 Device 013: ID 275d:0ba6  USB OPTICAL MOUSE 
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 002: ID 04f2:b71a Chicony Electronics Co., Ltd HD Webcam
Bus 001 Device 030: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

usbview

sudo usbview

image.png

上記の例では、Vendor ID は、
10c4
です。

serial.js を次のように書き換えます。

serial.js
(省略)
const filter = { usbVendorId: 0x10c4 };
port = await navigator.serial.requestPort({ filters: [filter] });
(省略)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?