Page 1 of 1

WebServer Page Update Rate.

Posted: Tue Nov 22, 2016 3:36 pm
by Jay Dee
Hi working with the basic Webserver example,
Using an ECIO40P (18F4455) and EBlocks with WIZ810MJ module.
The HTML is pretty close to the original;

Code: Select all

<html>
<head>
<title>Embedded Switch Monitor</title>

<script type="text/javascript">

function reFresh()
{
  location.reload(true)
}

window.setInterval("reFresh()",1000);

function checkSwitch()
{
  var temp = %1;

  if(temp > 100)
  {
	document.write(
'<span class=\\"style5\\"><b>Switch Value Over 100</b></span>');
  }
  else
  {
	document.write(
'<span class=\\"style4\\"><b>Switch Value Under 100</b></span>');
  }
}

</script>

<style type="text/css">
.style1 {
	font-size: xx-large;
	font-weight: bold;
	color: #0000FF;
}
.style2 {font-size: medium}
.style3 {font-size: medium; font-weight: bold; color: #0000FF; }
.style4 {color: #00FF00}
.style5 {color: #FF0000}
</style>
</head>
<body>
<p align="center" class="style1">
Embedded Switch Monitor<br>
  <br>
  <span class="style2">
System Status: <span class="style4">
Online</span></span></p>
<p align="center" class="style3">
Sensor Level Raw: %1 </p>
<p align="center" class="style3">
Sensor Level mm: %2 </p>
<p align="center" class="style3">
Sensor Temp C: %3 </p>
<p align="center" class="style3">
Switch Status: <script> checkSwitch() </script></p>
</body>
</html>
So I'm reading out a few extra variables and displaying them.
So my question is how can I make the Webpage, when viewed from an external web browser update quicker?
The FC is changing the values every ~500ms.
When I view the webpage with Chrome, the value will sometimes update around every 5 seconds and sometime stop and the page is reported unresponsive by Chrome.
I guess it to do with this simple Function, but the Value (1000ms) I think is a timeout rather than a refresh rate.

Code: Select all

function reFresh()
{
  location.reload(true)
}

window.setInterval("reFresh()",1000);
I'm a engineer not a coder so even basic HTML is a compleatly new field for me but if I can bash together some basic and reliable Input/Output from a Webserver is could be a fantastic tool for remote sensor projects.
Cheers, J.

Re: WebServer Page Update Rate.

Posted: Tue Nov 22, 2016 4:47 pm
by LeighM
Hi J.

Code: Select all

window.setInterval("reFresh()",1000);
That code tells the browser to request the page every second. (Or more accurately to request/refresh this page after an interval of 1 second)
How quickly the application is capable of responding is a different matter.
You could try reducing, or indeed removing, the 500ms delay in your loop to give the application more chance to detect and respond to the incoming request.

Leigh