This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Ethernet issue when transmit large data on TM4C1294

Other Parts Discussed in Thread: ENERGIA, EK-TM4C1294XL

Hello, I am new on Energia and I am trying to setup a webserver with html pages and images stored on a SD card.

The board is the TIVA C EK-TM4C1294XL and the Energia release 0101E0012.

The setup was running pretty well with simple pages.  However when using larger image (jpeg) files with a size like 20 kB, only an empty box is showed on the client browser.

In order to separate the reading flow from the SD and the writing operation to the Ethernet client, I am done a test program using a jpeg file stored into an array of char.

Doing a loop which writes each byte from the array and to the ethernet  client.write is not working, and the returned image to the browser has every time a size smaller than the array.

Therefore, when adding some delay or message output to the console (using Serial.print)  into the above loop, then the image is showed correctly every time. Therefore, the performance becomes very slow like 10 sec required to print a 20K jpeg image…

I am tested an alternative version based on 128 Byte buffer when calling client.write, but unfortunately the result is the same.

So, it looks like the Ethernet/TCP layer is affected by an overflow condition, therefore none error code has been reported.

Is someone has some knowledge about such issue or any suggestions.

Thanks for your help.

Here is the code used:

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include "inc/hw_sysctl.h"
#include "inc/hw_ssi.h"
#include <driverlib/sysctl.h>

#include <driverlib/rom.h>
#include <driverlib/rom_map.h>

#define LWIP_DEBUG

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

// tiger.jpg
const byte tiger_jpg[] = { 0xFF,0xD8,0xFF,0xE0,..........,0x4A,0x7F,0xFF,0xD9 };

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 0, 0, 10); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer


void setup()
{
    Serial.begin(115200);       // for debugging
   
    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++;
                }
                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // open requested web page file

                    if (StrContains(HTTP_req, "GET /tiger.jpg")) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: image/jpeg");
                        client.println();                      
                        
                        Serial.print("sizeof(tiger_jpg): ");
                        Serial.println(sizeof(tiger_jpg), DEC);
                        for (uint32_t i = 0; i < sizeof(tiger_jpg); i++) {
                            if ( (i & 0x7f) == 0x40) delay(10);
                           client.write(tiger_jpg[i]);
                        }   
                    } 

                    // 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
}
}