Skip to content
Snippets Groups Projects
Commit 07b36e9d authored by Kyrre Ness Sjobaek's avatar Kyrre Ness Sjobaek
Browse files

WEB server timeout + fix SPC timeout

parent b908c34a
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,7 @@ IPAddress subnet(255, 255, 0, 0);
// ***** OTHER CONFIG ***************************
const unsigned long update_interval = 1000; //[ms]
const unsigned long SPC_timeout = 5; //[ms] 260 us per 4-bit word, 13 words, plus some buffer
const unsigned long WEB_timeout = 600; //[ms] Max time allowed waiting for web client
// ***** GLOBAL VARIABLES ***********************
......@@ -261,7 +262,7 @@ void loop() {
void readSPCinstrument(uint8_t ch) {
unsigned long SPC_timeout_time = millis();
unsigned long SPC_timeout_time = millis()+SPC_timeout;
digitalWrite(pinREQ[ch],HIGH);
......@@ -378,10 +379,13 @@ void readSPCinstrument(uint8_t ch) {
void HTTPserver () {
unsigned long WEB_timeout_time = millis()+WEB_timeout;
EthernetClient client = srvWEB.available();
if(client) {
Serial.println();
Serial.println("New web client");
Serial.print("New web client ");
Serial.println(client.remoteIP());
}
else {
return;
......@@ -393,7 +397,7 @@ void HTTPserver () {
// We should also echo what the client sends
boolean currentLineIsBlank = true;
while(client.connected()) {
while(client.connected() and millis() < WEB_timeout_time ) {
if (client.available()) {
//WARNING: If client does not "do it's thing",
// the Arduino may become unresponsive.
......@@ -473,6 +477,12 @@ void HTTPserver () {
}
}
if ( millis() >= WEB_timeout_time) {
Serial.println();
Serial.println("WEB timed out.");
}
// give the web browser time to receive the data
delay(10);//[ms]
// close the connection:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment