From 04b0da5f5a81d251cc7da888789b7516ea6c3d11 Mon Sep 17 00:00:00 2001 From: Henrik Ekblad Date: Tue, 25 Mar 2014 23:47:14 +0100 Subject: [PATCH] Added a-lurkers proposed changes to speed up message porcessing. --- EthernetGateway/EthernetGateway.ino | 53 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/EthernetGateway/EthernetGateway.ino b/EthernetGateway/EthernetGateway.ino index 3004ab0..75fa991 100644 --- a/EthernetGateway/EthernetGateway.ino +++ b/EthernetGateway/EthernetGateway.ino @@ -127,35 +127,40 @@ void processEthernetMessages() // bytes available to read via the client object EthernetClient client = server.available(); - if (client) + if (client) { - // read the bytes incoming from the client - char inChar = client.read(); + // if got 1 or more bytes + if (client.available()) + { + // read the bytes incoming from the client + char inChar = client.read(); - // echo the bytes to the serial port - Serial.print(inChar); + if (inputPos