简体   繁体   English

Chrome 和 Web 串行 API。 如何在不询问的情况下获取端口

[英]Chrome & Web Serial API. How to get port without asking

I need your help.我需要你的帮助。

Is there a way to take control of a serial port, previously authorized, without using the popup window?有没有办法在不使用弹出窗口的情况下控制先前授权的串行端口? (without port = await navigator.serial.requestPort(); ) (没有端口 = 等待 navigator.serial.requestPort();

Thank you and sorry for my english, italian speaking here.谢谢你,对不起,我在这里说英语,意大利语。

I believe JS code below should work fine for you:我相信下面的 JS 代码应该适合你:

// Get all serial ports the user has previously granted the website access to.
const ports = await navigator.serial.getPorts();

Source: https://web.dev/serial/#open-port来源: https : //web.dev/serial/#open-port

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Chrome Web Serial API 上获取串口信息 - Getting Serial port info on Chrome Web Serial API 在 Chrome 上的 Web Serial API 中获取连接设备的名称 - Get name of connected device in Web Serial API on Chrome 谷歌浏览器 Web 串行 API:意外行为 - Google Chrome Web Serial API: unexpected behaviour 关于Chrome的同源政策的困惑:如何摆脱它而不要求用户禁用Chrome中的安全性? - Confusion about Chrome's same origin policy: how to get rid of it without asking the user disable security in Chrome? Chrome 中的串口通信 - Serial Port communication in Chrome Chrome Web Serial API 在 VueJs Web 应用程序中不起作用 - Chrome Web Serial API not working in VueJs Web app Google Chrome Web Serial API:如何配置Modbus RTU的参数? - Google Chrome Web Serial API: How do I configure the parameters for Modbus RTU? Chrome 扩展程序:如何使用串行端口(现在应用程序正在淘汰)? - Chrome extension: how to use serial port (now that apps are sunsetting)? Web Serial API - Uncaught (in promise) DOMException: Failed to open serial port / required member baudRate is undefined - Web Serial API - Uncaught (in promise) DOMException: Failed to open serial port / required member baudRate is undefined 网站上的谷歌浏览器扩展串口 - Google Chrome Extension serial port on website
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM