Chrome扩展程序:如何使用串行端口(现在应用程序正在停用)? [英] Chrome extension: how to use serial port (now that apps are sunsetting)?

查看:930
本文介绍了Chrome扩展程序:如何使用串行端口(现在应用程序正在停用)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



目标:我正在尝试写一些可以从我的浏览器与Arduino的COM端口进行交流的东西。 > 问题:我的第一个尝试是写一个扩展名。因此,我要求清单文件中 serial 的权限。当通过开发人员模式加载未打包的扩展时,我收到以下错误:'serial'仅适用于打包的应用程序,但是这是一个扩展。



我在这里看到 打包的应用是一个过时的术语,我猜他们只是意味着 Chrome应用程序。现在不幸的是,Chrome似乎也停止了这些Chrome应用,如这里讨论



问题:那么我应该如何访问系列 Chrome应用程序/扩展程序的功能/无论您使用哪个新名称? 您可以继续沿着相同的写作路径一个Chrome应用程序并使用chrome.serial API,但使用NW.js作为您的应用程序的运行时。它支持Chrome App API。基本上,你只需编写你的Chrome应用程序,而不是在Chrome中打开它,你可以在NW.js可执行文件中打开它。



https://nwjs.io/

或者你可以使用一个Node.js包(如serialport)来访问你的COM端口。


https://github.com/EmergingTechnologyAdvisors/node-serialport



在这种情况下,您可以将其编写为NW.js应用程序或Electron应用程序。电子最近很流行。您可以访问节点模块生态系统,也可以访问Chromium - Chrome网络浏览器的开源部分,因此您仍然可以执行所有您想要的HTML / JavaScript / CSS。



https://github.com/electron/electron



这也是Google推荐的路径之一:
https://developer.chrome.com/apps/migration#native


Aim: I am attempting to write a little "thing" that can talk from my browser to the COM port of an Arduino.

Issue: My first attempt is to write an extension. Therefore I am requesting permission for serial in my manifest file. When loading the unpackaged extension via developer mode I receive the following error: 'serial' is only allowed for packaged apps, but this is a extension.

I see here that packaged app is an outdated term and I guess they just mean Chrome app. Now unfortunately it seems that Chrome is also discontinuing these Chrome apps as discussed here.

Question: So how should I access the serial functionality of Chrome apps/extensions/whatever new name you come up with?

解决方案

You could continue on the same path of writing a chrome app and using the chrome.serial API, but use NW.js as the runtime of your app. It supports the Chrome App APIs. Essentially you just write your Chrome App but instead of opening it in Chrome you open it in NW.js executable.

https://nwjs.io/

Or you could use a Node.js package such as serialport to access your COM port

https://github.com/EmergingTechnologyAdvisors/node-serialport

In this case you could write it as either NW.js app, or an Electron app. Electron is quite popular lately. You have access to the node module ecosystem and also Chromium - open source part of Chrome web browser so you can still do all the HTML/JavaScript/CSS you want.

https://github.com/electron/electron

This is also one of the suggested paths from Google: https://developer.chrome.com/apps/migration#native

这篇关于Chrome扩展程序:如何使用串行端口(现在应用程序正在停用)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆