RS-232 and Ethernet shield on 1 UART?

Can an Arduino, with a single UART, use the ethernet shield and serial (via a max232 chip) at the same time? For instance, I need to do this:

#include <SPI.h>
#include <Client.h>
#include <Ethernet.h>
#include <Server.h>
#include <Udp.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 220 };			// ip in lan
byte gateway[] = { 192, 168, 1, 1 };			// internet access via router
byte subnet[] = { 255, 255, 255, 0 };                   //subnet mask
Server server(80);                                      //server port
int OnkyoPin = 13;  // Onkyo pin
String readString = String(30); //string for fetching data from address
boolean OnkyoON = false; //Onkyo status flag
void setup(){
//start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 13 to output
  pinMode(OnkyoPin, OUTPUT);  
//enable Serial1 datada print  
  Serial.begin(9600);
  Serial2.begin(9600);
}


void loop(){
// Create a client connection
Client client = server.available();
  if (client) {
    while (client.connected()) {
   if (client.available()) {
    char c = client.read();
     //read char by char HTTP request
    if (readString.length() < 100) 
      {
        //store characters to string 
        readString += c; //replaces readString.append(c);
      }  
        //output chars to Serial1 port
        Serial1.print(c);
        //if HTTP request has ended
        if (c == '\n') {
          //dirty skip of "GET /favicon.ico HTTP/1.1"
          if (readString.indexOf("?") <0)
          {
            //skip everything
          }
          else
          //lets check if Onkyo should be on
        if(readString.indexOf("L=1") >0)//replaces if(readString.contains("L=1"))
           {
             //Onkyo has to be turned ON
             digitalWrite(OnkyoPin, HIGH);    // set the Onkyo on
             OnkyoON = true;
           }else{
             //Onkyo has to be turned OFF
             digitalWrite(OnkyoPin, LOW);    // set the Onkyo OFF
             OnkyoON = false;             
           }
                 // now output HTML data starting with standart header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          //controlling Onkyo via checkbox
          client.println("<h1>Onkyo Control</h1>");
          //address will look like http://192.168.1.110/?L=1 when submited
          if (OnkyoON)
          client.println("<form method=get name=Onkyo><input type=checkbox name=L value=0>Onkyo
<input type=submit value=submit></form>");
          else
          
          /* prints value as string in hexadecimal (base 16) */
          
         
          client.println("<form method=get name=Onkyo><input type=checkbox name=L value=1>Onkyo
<input type=submit value=submit></form>");
          client.println("
");
          //printing Onkyo status
          client.print("<font size='5'>Onkyo status: ");
          if (OnkyoON)
              {
              client.println("<font color='green' size='5'>ON");
                  Serial2.write("!1PWR01") ; 
                  Serial2.print(13,BYTE);
              }
          else
              {
              client.println("<font color='grey' size='5'>OFF");
                 Serial2.write("!1PWR00") ; 
                 Serial2.print(13,BYTE);
              }
          client.println("</body></html>");
          //clearing string for next read
          readString="";
          //stopping client
          client.stop();
            }
          }
        }
      }
 }

Do I need the Mega 2560 and serial2 or could I do it all on the same UART from something like an UNO?

Can an Arduino, with a single UART, use the ethernet shield and serial (via a max232 chip) at the same time?

Yes

Awesome. So what are the limitations of a single UART then?

So what are the limitations of a single UART then?

Is this a trick question? The limitation of a single UART is that there is only one of them.

But doesn't the ethernet shield use the UART? So how can the shield and the max232 use the same UART? So my question is, where do you draw the line? Surely you can't put a max485, max232, ethernet shield, and use the USB port all at the same time on an UNO, right?

I thought the Ethernet shield used SPI.

But doesn't the ethernet shield use the UART?

It has been my experience that the answer to that question is no.

AFAIK Ethernet shields use SPI.


Rob

Ok. I was just assuming that the ethernet shield used the UART since part of the ethernet code is "serial.print(c)"