12

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?

SCBuergel
  • 1,613
  • 16
  • 26
  • 2
    Since this is not implemented currently the only thing you can do is to request this feature on https://crbug.com, #chromium IRC channel, [public group](https://groups.google.com/a/chromium.org/forum/#!forum/chromium-extensions). – wOxxOm May 27 '17 at 13:02
  • thanks, done (https://bugs.chromium.org/p/chromium/issues/detail?id=727018# and https://groups.google.com/a/chromium.org/forum/#!topic/chromium-extensions/iUrvfoVjTyQ). Though I feel hardware interfacing is such a massive requirement that I cant be the one wining the loudest for my little garden project.... – SCBuergel May 27 '17 at 13:23

2 Answers2

3

"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.

ata
  • 3,398
  • 5
  • 20
  • 31
James
  • 5,635
  • 2
  • 33
  • 44
1

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

Tom Dunn
  • 2,425
  • 2
  • 13
  • 9