Closed janbbeck closed 2 years ago
Are you sure that the needed flags are not enabled by default? It is my understanding that with the latest releases of google chrome and Microsoft edge that these were enabled by default. Release notes for chrome 89 list web serial api and also references how to disable for enterprise users. Release notes: https://storage.googleapis.com/support-kms-prod/aECCgflTiya0jTzyQXkX6Bi0np9Ue6dGKkr6 Feature status: https://www.chromestatus.com/feature/6577673212002304
Maybe they changed it in some recent version, but the version that is shipped with the current Raspian does need to have it enabled. Tough they ship a pretty old one. I am currently recompiling chromium 90 for that Pi Zero, but it looks like the compile time will be 10 days!
Chrome on a pi zero sounds like no no fun at all. You might want to look in to a command line method of talking to the serial port. Running X and chromium would be unbearably slow I imagine. Even the pi3 is rather painful for GUI stuff.
You might consider using minicom or screen to connect to serial devices from the command line.
See the following examples
screen /dev/device baud-rate
screen /dev/ttyS0 19200
screen /dev/ttySUSB0 19200,cs8
You might also look at this link for some options. https://www.cyberciti.biz/hardware/5-linux-unix-commands-for-connecting-to-the-serial-console/
Thanks for the suggestions. Screen works fine, of course. I'm evaluating the possibility of using the Pi Zero as a cheap adapter to turn serial data into a basic graphical display via HDMI. It may be too slow, I know... :P
I should say that browsing with the built-in chrome was so-so at 1080p. So maybe at a quarter that resolution, it will work as a display...
Just confirmed. Downloaded latest Raspbian and updated to latest software using apt. Uses Chromium version 88
Ok, the data seems to come in and the web page updates quickly enough, but only if I plug and unplug the wire going in to the RX. As long as I leave the wire plugged in, there is no update. It just suddenly updates the window when I unplug the line.
Ideas?
update: the performance improves dramatically after just updating GUI elements and removing the text box altogether. For example:
// appendToTerminal(value);
if (value.startsWith("vrms:")) {
// starts with marker for voltage
if (value.indexOf("\n") != -1) {
// got the whole line
voltageString = value.substring(5);
var voltValue = parseInt(voltageString);
if (typeof voltValue != "undefined") {
if (typeof voltValue === "number") {
if (!isNaN(voltValue)) {
document.getElementById("voltage").value = voltValue;
document.getElementById("voltage1").innerHTML ="Voltage: " + voltValue + " V";
}
}
}
}
}
where voltage is a < meter > tag and voltage1 is a < H1> tag.
And under android I get serial connection failed, even when enabling the experimental features (which are also disabled there by default; v91) using terminal program under android works fine.
@janbbeck I do not believe that android has support for serial devices to be recognized by the browser at the moment. As far as I know no USB to serial drivers are built in to the android kernel. To interface with USB to serial devices from android the driver has to be built to use the raw USB functionality and package its own drivers in to the app.
If you were able to get this working on an android device I would be interested in knowing the manufacturer and model number along with the android and chrome versions.
Interesting. However, the API that serialTerminal is using can also access USB devices via the USB ids, can it not? Any way to enable serial devices that way?
No. There is a separate webUSB api but you need to write a specific driver to interface with a particular USB to serial converter. IE. Not universal.
I found serialterminal.com though your posting here: https://stackoverflow.com/questions/30114474/communicate-with-the-serial-port-from-client-web-browser
In that page, there is some important information, that I think you should add to the readme, namely that
"As you can imagine, this is API is only supported by modern Chromium based desktop browsers right now (April 2020) but hopefully support will improve in the near future. At this moment you need to enable your browser's Experimental Web Platform Features, just copy and paste the right URL:
chrome://flags/#enable-experimental-web-platform-features opera://flags/#enable-experimental-web-platform-features edge://flags/#enable-experimental-web-platform-features "