Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Serial
  4. getPorts()

Serial: getPorts() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Note: This feature is available inDedicated Web Workers.

ThegetPorts() method of theSerial interface returns aPromise that resolves with an array ofSerialPort objects representing serial ports connected to the host which the origin has permission to access.

Syntax

js
getPorts()

Parameters

None.

Return value

APromise that resolves with an array ofSerialPort objects.

Exceptions

SecurityErrorDOMException

The returnedPromise rejects with this error in either of the following situations:

Examples

The following example usesgetPorts() to initialize a list of available ports.

js
navigator.serial.getPorts().then((ports) => {  // Initialize the list of available ports with `ports` on page load.});

Specifications

Specification
Web Serial API
# dom-serial-getports

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp