Added a-lurkers proposed changes to speed up message porcessing.

This commit is contained in:
Henrik Ekblad
2014-03-25 23:47:14 +01:00
parent 01d06cd034
commit 04b0da5f5a
+8 -3
View File
@@ -128,19 +128,23 @@ void processEthernetMessages()
EthernetClient client = server.available(); EthernetClient client = server.available();
if (client) if (client)
{
// if got 1 or more bytes
if (client.available())
{ {
// read the bytes incoming from the client // read the bytes incoming from the client
char inChar = client.read(); char inChar = client.read();
// echo the bytes to the serial port
Serial.print(inChar);
if (inputPos<MAX_RECEIVE_LENGTH-1) { if (inputPos<MAX_RECEIVE_LENGTH-1) {
// if newline then command is complete // if newline then command is complete
if (inChar == '\n') if (inChar == '\n')
{ // a command was issued by the client { // a command was issued by the client
// we will now try to send it to the actuator // we will now try to send it to the actuator
inputString[inputPos] = 0; inputString[inputPos] = 0;
// echo the string to the serial port
Serial.print(inputString);
gw.parseAndSend(inputString); gw.parseAndSend(inputString);
// clear the string: // clear the string:
@@ -157,6 +161,7 @@ void processEthernetMessages()
} }
} }
} }
}