Go Down

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

blastboot

it makes sense   :)  in my code i have
Code: [Select]
int16_t c;
          while ((c = file.read()) >= 0) {
client.print((char)c);
          }

adapting it with the information you provide, is something like
Code: [Select]
byte clientBuf[64];
            int clientCount = 0;
              clientBuf[clientCount] = file.read();
              clientCount++;

              if(clientCount > 63)
              {
                // Serial.println("Packet");
                client.write(clientBuf,64);
                clientCount = 0;
              }
           
            //final <64 byte cleanup packet
            if(clientCount > 0) client.write(clientBuf,clientCount);           
            // close the file:
            file.close();

is this right?

SurferTim

I didn't compile it, but that looks like it!  :)

blastboot

Thanks i'll try it because i have the same speed problem with images.
One more thing... what does this line exactly do?
Code: [Select]
if(clientCount > 0) client.write(clientBuf,clientCount);

SurferTim

That sends the last packet. Unless you are really lucky, your files will not be an even multiple of 64, so there may be a few bytes remaining in that buffer when the file read is finished.


Go Up