Reputation: 1653
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?
Upvotes: 12
Views: 8588
Reputation: 6103
"Web Serial API", navigator.serial
, may be the best way looking forward. It has been available behind the #enable-experimental-web-platform-features
flag in chrome://flags
since chrome 77. It is due to go to Origin trials 80-82 then ship in 83.
Web Serial API allows serial interface directly from a progressive web app. There is a good tutorial at https://codelabs.developers.google.com/codelabs/web-serial/#0
You should probably avoid the older chrome.serial
, available only in chrome apps, because from June 2020 Chrome Apps on Windows, Mac, and Linux will no longer be supported.
Upvotes: 3
Reputation: 2455
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.
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
Upvotes: 1