Go Down

Topic: Why's SD -> Ethernet Card -> Webbrowser so slow? (Read 6 times) previous topic - next topic

Kong

Hello guys,

Not a real problem, but could somebody explain why data transfer is so terribly slow:

I've an Arduino Ethernet card with 8GB SD card.
This SD card contains a complete html code including several jpg's and png's files.
It's all working fine: the webbrowser gives a request, arduino delivers the html page via the SD card, the webbrowser asks for the images (as put in the html file) and Arduino sent the files.
But an image of approx. 150kB takes about 20 seconds to load, what's the bottleneck around here?
(Arduino, Wiznet 5100, SD card, libraries..)

In all my simplicity :smiley-slim: I think: 8 MHz arduino, pick a byte from SD, sent it over the internet etc., 150kB shouldn't take 20 seconds?


mohamed66

hi ,
how you make arduino open webpage on sd card having pictures and open it .. i tried to do that for 2 days and failed at the end
any help please

zoomkat

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)


SurferTim

#4
Feb 18, 2013, 01:31 pm Last Edit: Feb 18, 2013, 04:09 pm by SurferTim Reason: 1
If you want to avoid the fate of the OP, then you need to send these files more than one byte per packet. If you are sending a big file, this will take relatively forever.
Code: [Select]
           while (myFile.available()) {
             client.write(myFile.read());
           }
           // close the file:
           myFile.close();


This sends the data in 64 byte packets, rather than one byte per packet.
Code: [Select]
 Serial.println("Writing");

 byte clientBuf[64];
 int clientCount = 0;

 while(fh.available())
 {
   clientBuf[clientCount] = fh.read();
   clientCount++;

   if(clientCount > 63)
   {
     Serial.println("Packet");
     client.write(clientBuf,64);
     clientCount = 0;
   }
 }

 if(clientCount > 0) client.write(clientBuf,clientCount);


edit: If you want it to work really fast, remove or comment out the Serial.println("Packet") statement. That was just for debugging.

Go Up