USB / Serial

In this section you will learn how to get information about detected USB devices and serial / COM ports:

For function reference and examples we assume, that we imported systeminformation as follows:

const si = require('systeminformation');

Detected USB Devices and Serial Ports

All functions in this section return a promise or can be called with a callback function (parameter cb in the function reference)

Function Result object Linux BSD Mac Win Sun Comments
si.usb(cb) [{...}] X X X array detected USB devices
[0].bus X USB bus
[0].deviceId X Bus device ID
[0].id X X X ID e.g. 0bda:8821
[0].name X X X name, e.g. root hub
[0].type X X X type e.g. keyboard or mouse
[0].removable X is removable
[0].vendor X X vendor e.g. Realtek
[0].manufacturer X X X manufacturer e.g. Chicony
[0].maxPower X max power e.g. 100mA
[0].serialNumber X serial number if available
Example
const si = require('systeminformation');
si.usb().then(data => console.log(data));
[
  {
    bus: 1,
    deviceId: 2,
    id: '8087:8001',
    name: '',
    type: 'Hub',
    removable: null,
    vendor: 'Intel Corp.',
    manufacturer: '',
    maxPower: '0mA',
    serialNumber: null
  },
  {
    bus: 1,
    deviceId: 1,
    id: '1d6b:0002',
    name: '2.0 root hub',
    type: 'Hub',
    removable: null,
    vendor: 'Linux Foundation',
    manufacturer: 'Linux 4.4.0-169-generic ehci_hcd',
    maxPower: '0mA',
    serialNumber: null
  },
  {
    bus: 2,
    deviceId: 4,
    id: '04f2:0402',
    name: 'Genius LuxeMate i200 Keyboard',
    type: 'Keyboard',
    removable: null,
    vendor: 'Chicony Electronics Co., Ltd',
    manufacturer: 'Chicony',
    maxPower: '100mA',
    serialNumber: null
  },
  {
    bus: 2,
    deviceId: 3,
    id: '093a:2510',
    name: 'Optical Mouse',
    type: 'Mouse',
    removable: null,
    vendor: 'Pixart Imaging, Inc.',
    manufacturer: 'PIXART',
    maxPower: '100mA',
    serialNumber: null }
]
si.serialPorts() [{...}] X X X array of detected serial / COM ports
[0].device X X X device path, e.g. /dev/ttyUSB0 (COM3 on Windows)
[0].name X X X product / friendly name
[0].manufacturer X X X manufacturer e.g. FTDI
[0].serialNumber X X X serial number (USB ports only)
[0].vendorId X X X vendor id (hex) e.g. 0403
[0].productId X X X product id (hex) e.g. 6001
[0].pnpId X X stable id (by-id on Linux, DeviceID on Windows)
[0].type X X X usb, onboard, pci, bluetooth, virtual, unknown
Example
const si = require('systeminformation');
si.serialPorts().then(data => console.log(data));
[
  {
    device: '/dev/ttyUSB0',
    name: 'FT232R USB UART',
    manufacturer: 'FTDI',
    serialNumber: 'A50285BI',
    vendorId: '0403',
    productId: '6001',
    pnpId: 'usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0',
    type: 'usb'
  },
  {
    device: '/dev/ttyS0',
    name: 'ttyS0',
    manufacturer: null,
    serialNumber: null,
    vendorId: null,
    productId: null,
    pnpId: null,
    type: 'onboard'
  }
]

Known issues

Serial Ports

serialPorts() only enumerates ports - opening one (baud rate, termios, RTS toggling for half duplex) needs a native binding and is therefore out of scope for this zero-dependency library.

On Linux a port is listed even when the current user is not a member of the dialout / uucp group, so listing can succeed while opening the port fails with a permission error.

On Windows the COMx number is reassigned per USB port, so pnpId is the only stable key to identify a specific adapter.

RS-232 and RS-485 cannot be told apart by enumeration - an RS-485 transceiver looks like an ordinary UART to the operating system - so no such information is reported.