SoftwareSerial.h causing Ethernet sheild to fail to work correctly

Working on web page that will allow me to remote control an RS-232 controlled video switcher. I am putting the arduino ‘inline’ of the RS-232 cable. So that the PC with the software can talk to the video switcher, video can talk to the PC. But with arduino being the ‘middle man’ It can push it’s own commands that are activated via web page.

The webpage interaction works by itself on the Ethernet shield. (Web pages hosted on its SD card). RS-232 pass throu works fine by its self. (PC can talk to switcher, and switcher to PC by way of arduino)

This is on an Arduino Uno. Using SoftwareSerial.h to create the second RS-232 port. (Connected to D2 and D3 for RX and TX).

When I added the serial code to the ethernet/webpage code. The webpage no longer loads. I have narrowed it all down to one line: #include <SoftwareSerial.h>
If that include is present, the webpage fails to load. If I comment it out, the webpage is working perfectly. Do you know what could be causing this issue. and do you know a way I can have both Ethernet sheild and SoftwareSerial in the same code and play nice with each other?

/*--------------------------------------------------------------
// http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-IO/
 Program:      eth_websrv_SD_link
 Software:     Developed using Arduino 1.0.5 software
 Should be compatible with Arduino 1.0 +
 
 Requires index.htm and page2.htm to be on the
 micro SD card in the Ethernet shield micro
 SD card socket.
  References:   - WebServer example by David A. Mellis and 
 modified by Tom Igoe
 - SD card examples by David A. Mellis and
 Tom Igoe
 - Ethernet library documentation:
 http://arduino.cc/en/Reference/Ethernet
 - SD Card library documentation:
 http://arduino.cc/en/Reference/SD
 
 Date:         2 March 2013
 Modified:     14 June 2013
 - removed use of String class, used too much SRAM
 - added StrClear() and StrContains() functions
 - disable Ethernet chip at startup
 
 Author:       W.A. Smith, http://startingelectronics.com
 --------------------------------------------------------------*/

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <SoftwareSerial.h>

// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   30

// MAC address from Ethernet shield sticker under board
byte mac[] = { 
  0x90, 0xA2, 0xDA, 0x00, 0x9A, 0x59 };
IPAddress ip(10, 0, 0, 88);   // IP address, may need to change depending on network
EthernetServer server(80);       // create a server at port 80
File webFile;                    // handle to files on SD card
char HTTP_req[REQ_BUF_SZ] = {
  0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer


int extron_input = 0;
int extron_output = 0;
int questionmark_pos = 0;

void setup()
{
  // disable Ethernet chip so it will look to the SD card.
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

  Serial.begin(9600);       // for debugging

  // initialize SD card
  Serial.println("Initializing SD card...");
  if (!SD.begin(4)) {
    Serial.println("ERROR - SD card initialization failed!");
    return;    // init failed
  }
  Serial.println("SUCCESS - SD card initialized.");
  // check for index.htm file
  if (!SD.exists("index.htm")) {
    Serial.println("ERROR - Can't find index.htm file!");
    return;  // can't find index file
  }
  Serial.println("SUCCESS - Found index.htm file.");

  Ethernet.begin(mac, ip);  // initialize Ethernet device
  server.begin();           // start to listen for clients
}

void loop()
{
  EthernetClient client = server.available();  // try to get client

  if (client) {  // got client?
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {   // client data available to read
        char c = client.read(); // read 1 byte (character) from client
        // buffer first part of HTTP request in HTTP_req array (string)
        // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
        if (req_index < (REQ_BUF_SZ - 1)) {
          HTTP_req[req_index] = c;          // save HTTP request character
          req_index++;
        }

        //Serial.print(c);    // print HTTP request character to serial monitor
        // last line of client request is blank and ends with \n
        // respond to client only after last line received
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();
          // open requested web page file

          if (StrContains(HTTP_req, "GET / ")
            || StrContains(HTTP_req, "GET /index.htm")) {
            webFile = SD.open("index.htm");        // open web page file
          }
          else if (StrContains(HTTP_req, "GET /page2.htm")) {
            webFile = SD.open("page2.htm");        // open web page file
          }
          else if (StrContains(HTTP_req, "GET /temperat.htm")) {
            webFile = SD.open("temperat.htm");        // open temperature sensors.
          }


          // -######################################################################################           
          // -###################################################################################### 
          else if (StrContains(HTTP_req, "GET /livingrm.htm")) {
            webFile = SD.open("livingrm.htm");        // open web page file

            if (StrContains(HTTP_req, "?i")) {
              Serial.println("Living Room Input");
              // ADD: Set Extron_Output=Lvingroom
              extron_output = 5;
              extron_input_select();

              // ADD: Set Extron_Input= ?___   // What ever is after the 01. It will set the value to. So if ?i12. Then it is looking for Input 12
              //int questionmark_pos = HTTP_req.indexOf('?');
              //Serial.println(questionmark_pos);

              //int STHTTP = StrContains(HTTP_req);
              //Serial.print("Extron Input ");
              //Serial.println(questionmark_pos);
              //Serial.println(HTTP_req);

            }
          }

          // -###################################################################################### 
          // -###################################################################################### 

          else if (StrContains(HTTP_req, "GET /mstbrm.htm")) {
            webFile = SD.open("mstbrm.htm");        // open web page file
            if (StrContains(HTTP_req, "?i")) {
              Serial.println("Master Bedroom Input");
              extron_output = 4;
              extron_input_select();
              /*
              Serial.print("Extron Output ");
              Serial.println(extron_output);

              Serial.print("Extron Input ");
              Serial.println(questionmark_pos);
              */
            }
          }


          if (webFile) {
            while(webFile.available()) {
              client.write(webFile.read());
            }
            webFile.close();
          }
          // reset buffer index and all buffer elements to 0
          req_index = 0;
          StrClear(HTTP_req, REQ_BUF_SZ);
          break;
        }
        // every line of text received from the client ends with \r\n
        if (c == '\n') {
          // last character on line of received text
          // starting new line with next character read
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // a text character was received from client
          currentLineIsBlank = false;
        }
      } // end if (client.available())
    } // end while (client.connected())
    delay(1);      // give the web browser time to receive the data
    client.stop(); // close the connection
  } // end if (client)
}

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
  for (int i = 0; i < length; i++) {
    str[i] = 0;
  }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
  char found = 0;
  char index = 0;
  char len;

  len = strlen(str);

  if (strlen(sfind) > len) {
    return 0;
  }
  while (index < len) {
    if (str[index] == sfind[found]) {
      found++;
      if (strlen(sfind) == found) {
        questionmark_pos = (int) index; //Sets the int based on where the ? is found.
        return 1;
      }
    }
    else {
      found = 0;
    }

    index++;

  }
  // Serial.println(index,DEC);
  return 0;
}

What Arduino are you using? I’m guessing that you are running out of memory, with all those string literals that are unnecessarily copied to SRAM.

client.println(F(“HTTP/1.1 200 OK”));

PS: Learn to use your damned enter key!

Arduino Uno Rev3.

When I ctrl+u a page. I get nothing in the source code. (no text at all) I have the pages hosted on the sd card for the reason of opening up a bit of the ram.

And I am unclear as what you mean about the enter key. A good section of the html code is copy pasted.

The software serial port operates differently than the hardware serial port and might be causing timing issues.

The software serial port operates differently than the hardware serial port and might be causing timing issues.

Not likely, since OP isn't even creating an instance of the class.

And I am unclear as what you mean about the enter key. A good section of the html code is copy pasted.

              // ADD: Set Extron_Input= ?___   // What ever is after the 01. It will set the value to. So if ?i12. Then it is looking for Input 12

There is no excuse for putting a comment this long on one line. Having to scroll back and forth and up and down to get to the scroll bars on the code window makes me want to just hit the back button and ignore you.

When I ctrl+u a page. I get nothing in the source code.

So? The Arduino has crashed because it ran out of memory long before it got to sending anything. It's hardly a surprise.

PaulS, I ran on your hunch that it was the ram. Last night I had worked on the code to get everything ready for the SoftwareSerial stuff. I had commented out ALL of the Serial.printn()'s as they would effect the switchers response.

Reading over what you had said along with some research. You were correct, the RAM was the issue. I put back in the #include SoftwareSerial.h. and it worked fine. Along with the residual code so it would echo serial0 to serial1 and vice versa.

The code is now fully written and is working flawlessly!
TL;DR: All of the Serial.println() for trouble shooting were commented out. This allowed the arduino the abilty to 'think' and process correctly. The Web pages now load correctly with no issues. The RS232 thruput is working correctly. and the Arduino can now send out a syntax to the switcher with no issues.

Much thanks for the assistance! As for the enter stuff. I have a big monitor and view the code in full screen. I also tend to 'rant' in my comments to help me out when I come back to something 6 months later to know what it did.