Question re: HTML served by Micromite


Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3811
Posted: 05:15am 29 Apr 2017      

"[ser2net] is open source thought so you might be able to adapt the code to inspect the data coming from the serial port for a special character or escape sequence to close the tcp connection."

That sounds hard. Easier to count the characters. I tried to make it so that there were few if any variations in the length of the served text. This involved changing the full month and day names to 3-character shortenings, replacing the color names "chartreuse" and "red" with their hex codes, "#7fff00" and "#ff0000", and putting "......." in checkboxes and radio boxes not "checked" (which browsers ignored).

Then I ran through my output routine, counting but not outputting the characters. That gave me a "Content-Length" to plug in when I actually output the HTML upon receiving a browser request. I padded the end with some extra spaces.

As a result, the connection successfully closes now on Chrome and IE and Firefox on the PC, and the glitches with Chrome which required "Reload" have ceased. It also works on Android with Chrome. On Android with Opera, the first request works, but subsequent updates result in the HTML code being printed as text, even when I include "<!DOCTYPE html>" at the beginning (that displays too, and the same without it).

So even with a remaining glitch with one browser on Android, I am happy with the solution. Thanks very much for all the suggestions.

Edited by lizby 2017-04-30