If you’re looking to expand your knowledge, this guide is designed to help you grasp the basics of getInfo().
However, in the Web Serial API, there is a getInfo() method in the SerialPort interface.
This method gives back an object that has properties showing the vendor ID and product ID of a device.
Web Serial API
An object that holds the following values.
If the port belongs to a USB device, it will have an unsigned short integer that represents the vendor of the USB device. Otherwise, it will be undefined.
If the port belongs to a USB device, it will have a number that identifies the USB device. Otherwise, it will be undefined.
const port = await navigator.serial.requestPort(); const info = port.getInfo(); console.log(info.usbVendorId); console.log(info.usbProductId);
This code requests access to a serial port, then calls the getInfo() method on the SerialPort object to get information about the device.
The usbVendorId and usbProductId properties of the returned object contain the vendor ID and product ID of the device, respectively.
This article highlighted that the getInfo() method in the Web Serial API returns an object containing the vendor ID and product ID of a USB device, if applicable.
It also provided the syntax, parameters, and return value of the method, along with information about browser compatibility.
Additionally, the article included a code example demonstrating how to use the getInfo() method to retrieve device information.
You can also check out the following article:
Thank you for reading itsourcecoders 😊.