device.scan serial

device.scan serial

device.scan serial

Function

Scan the system serial port and return the serial port information array.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
typeStringNoserialDevice type; currently only serial is supported.

Return value

TypeDescription
ArrayReturns an array of serial port information objects.

Serial port information field

The fields of each serial port information object in the array are as follows:

FieldTypeMust existDescription
typeStringYesDevice type, fixed to serial.
portStringYesSystem serial port name. Common values for Windows are COM3; common values for Linux/macOS are /dev/ttyUSB0, /dev/tty.usbserial. Passed to device.open({port: ...}) when opening the serial port.
nameStringYesThe friendly name of the device. The USB serial port preferentially uses the product name or manufacturer name; if it cannot be recognized, it will equal port.
kindStringYesSerial port source type. Common values are usb, bluetooth, pci, unknown.
vidIntNoUSB Vendor ID. Only exists when the USB serial port can recognize the manufacturer ID.
pidIntNoUSB Product ID. Only exists when the USB serial port can recognize the product ID.
serial_numberStringYesUSB device serial number; empty string if not provided by the system.
manufacturerStringYesUSB device manufacturer name; empty string if not provided by the system.
productStringYesUSB device product name; empty string if not provided by the system.

Example

Notes

  • vid and pid only exist if the hardware ID is recognized by the USB serial port.
  • serial_number, manufacturer, product fields must exist, but are empty strings when the system does not provide corresponding values.