3 Replies Latest reply on Nov 3, 2013 1:01 AM by Fab64

    Ethernet Library performance issue

    Fab64

      , Hi all,

      I have discovered a performance issue in the available() function of client when data are not present to be read.

       

      This is the test code:

       

      void loop() {

       

        EthernetClient client = server.available();

       

        if (client) {

       

          Serial.println("new client");

       

          while (client.connected()) {

         

           unsigned long startTime = millis();

         

            if (client.available()) {

           

              char c = client.read();

              Serial.write(c);

            }

         

           unsigned long endTime = millis();

        

           Serial.print("Time out "); Serial.println((endTime-startTime));

          }

       

          delay(1);

          client.stop();

          Serial.println("client disonnected");

        }

      }

       

      When running on Galileo the timeout printed is about: 5005 ms, when running on Arduino Mega 2560 the timeout printed is about: 0/1 ms.

       

      As you can immagine, this long time spent on the available() function has a tremendous impact on the performances of all the sketch.

       

      Is there anything to do for reducing the timeout of the function ?

       

      Thanks