I'm using WebSerial API to use thermal-printer in chrome browser, and want to access only 'COM1' port without requestPort.
Can I access to specific port and using that port?
I'm using WebSerial API to use thermal-printer in chrome browser, and want to access only 'COM1' port without requestPort.
Can I access to specific port and using that port?
For security purposes user consent is needed for the WebSerial API
.
document.querySelector('button').addEventListener('click', async () => {
// Prompt user to select any serial port.
const port = await navigator.serial.requestPort();
});
After the first connection you could use this code to access previously consented ports by user
// Get all serial ports the user has previously granted the website access to.
const ports = await navigator.serial.getPorts();