Candas1/Hoverboard-Web-Serial-Control

Console not working in macOS using Chrome

justinotherguy opened this issue · 9 comments

Guten Tag,

after discovering this very useful tool I figured, it won't work for me in macOS.

My environment:
macOS 10.15.7 (19H15)
Chrome Version 87.0.4280.88 (Official Build) (x86_64)

I've tried the console with Linux (Mint 19.3) with Chromium and it works on that.

The behaviour:

  • I open https://candas1.github.io/Hoverboard-Web-Serial-Control/
  • I leave all settings to default
  • I click on the flash
    • a popup appears that lists all me serial ports
    • I select the desired one and click on "Connect"
      -> the popup disappears (as expected)
  • in the console view the flash icon does not change to "disconnect"
    -> nothing else happens

Is there anything else I need to do?

Regards from Baden, J.

Hi,

Unfortunately I could never try it on anything else than windows or android.

What do see in the console if you right click and select inspect option in chrome?

yes, sure:

serial.js:149 Uncaught (in promise) DOMException: Failed to open serial port.
connectSerial @ serial.js:149
async function (async)
connectSerial @ serial.js:111
connect @ serial.js:102
onclick @ (index):88

Does that help?

Sorry I am not a Linux expert.
Is there a chance you don't have proper permissions for that port?

Another comment. I think the serial connection should also work from macos

Sorry I am not a Linux expert.
Is there a chance you don't have proper permissions for that port?

I can open the port fine as the same user on the same machine (in terminal via screen and from VS code).
So, I think this should not be a permission issue. (This should also answer your second comment).

But... :)

...based on your questions I've checked, whether I can use the serial port with Chrome for a different app.
And so I came across https://www.espruino.com/ide/ -> https://www.espruino.com/Quick+Start+BLE
They explain, that Chrome's flag "experimental-web-platform-features" needs to be enabled:
chrome://flags/#enable-experimental-web-platform-features

That was all that was missing :)

So - thanks for pointing me in the right direction; maybe you want to add that hint to your docs.

The thing I don't understand:
why does it work in Chromium without this flag turned on?
So...I just downloaded Chromium for macOS - it also requires the flag to be set.
So it seems, this is not required for Linux or only on macOS.

Actually I had documented that this flag had to be enabled, but then I used something called Chrome origin trials, that let's you use those features without enabling. So I removed it from the documentation. If the api is not enabled I show a message in the log view also. It wasn't displaying in chromium?

well:

  • no, I don't see a message in the log view
  • I don't use Chromium, I use Chrome (not sure this makes a difference to you)

This is where I check if serial API is available.

if ("serial" in navigator === false) {

Do you mind checking why it's not showing up in your case? You should be able to query this property from the console. Then I will be able to improve how I handle such cases.

Are you downloading the code and executing locally ?

This is what I get if I run the tool locally in Microsoft Edge:
image

If I execute it from the github pages it just works without activating it:
https://candas1.github.io/Hoverboard-Web-Serial-Control/