Skip to content

Instantly share code, notes, and snippets.

@thexmanxyz
Last active March 6, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thexmanxyz/529a10ac6ab3434377352f24e1350d0a to your computer and use it in GitHub Desktop.
Save thexmanxyz/529a10ac6ab3434377352f24e1350d0a to your computer and use it in GitHub Desktop.
Arduino - SD.h / Ethernet.h - Buffered file read / write
int bufferSize = 64; // buffer size you want to use
while(file.available()) // file you previously pointed at
{
char buffer[bufferSize];
memset(buffer, '\n', bufferSize); // don't forget to fill the buffer with \n to prevent errors on last buffer read
file.read(&buffer, bufferSize); // read from file
client->write(buffer, bufferSize); // write to client
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment