I am trying to adapt an example sketch to send a file from SD card to browser.
I have it working but I don’t receive the entire file.
The issue appears to be EOF detection. The original line of code is:
while ((c = file.read()) > 0)
I am not familiar with the language (only had Arduino a week) but, as I understand it, the ‘0’ is used as an EOF marker.
I am also assuming that this signifies null rather than zero. However, in either case, this will fail if a null or zero byte exists in the file. I have tested with a file having null as the fourth byte and I only receive a file containing 3 bytes (it should be ~8k)!
Is there a simple, reliable method of detecting EOF? Alternatively, a simple way to get the file size?
Something like: while not EOF() would have been nice but…
Any advice would be appreciated - I’ve been looking for a solution for days!