Go Down

Topic: maximum time spent in while loop ? (Read 597 times) previous topic - next topic

simkard

Hi all,

I'm just wondering how many times does the µC can waits inside a while loop before the watchdog of it quits this while loops ?

I'm asking this because i'm streaming a file directly from the SD card and it seems that when the file is bigger than 50kB, the while loop ends !
Is this problem related with the watchdog or do i have to look further in my code for finding my mistake ?



Thanks !

CrossRoads

Did you do anything to explicitly turn the watchdog on?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

simkard

#2
Nov 25, 2011, 09:58 am Last Edit: Nov 25, 2011, 11:08 am by simkard Reason: 1

Did you do anything to explicitly turn the watchdog on?


Hi,

Errr ... Definitely not !
But i can confirm that when i strem a file from the µSD slot, if the file excess some size, the stream stops by itself on a regular basis.


EDIT : Please forgive me about my question ... I put a timeout earlier in my code for closing connection if there is no activity during 3000ms.
You can hit me if you want/need hahaha  :smiley-mr-green:

EDIT2 : ERRATUM !!! I think the problem is linked to the SD library.
-> I removed the timeout on my function and it continues to end at the same filesize transmitted.

simkard

#3
Nov 25, 2011, 11:20 am Last Edit: Nov 25, 2011, 11:25 am by simkard Reason: 1

EDIT2 : ERRATUM !!! I think the problem is linked to the SD library.
-> I removed the timeout on my function and it continues to end at the same filesize transmitted.


My function actually looks this code :
Code: [Select]

while (dataFile.available()){
  TEMP_SD_READ_BYTE = dataFile.read();
  HTTP_CLIENT.print(TEMP_SD_READ_BYTE);
}


The while loop ends systematicaly and respectively on the same file size for each file i try to download :
a GIF file : 12980 bytes
a JPG file : 20304 bytes

The speed of the connexion is ~5 ko/s.

I'm wondering if the command "dataFile.available()" is not running too fast and not permitting the result to update itself and becoming, at least, more than 1.

EDIT : i tried to add a "delay(1);" at the end, before the while loop ... loops, and then, i have to exact same problem (except that the result takes longer to obtain).
-> I'm definitely thinking there must be some kind of problem with the SD library.

Graynomad

Quote
I'm definitely thinking there must be some kind of problem with the SD library.

99.9% of the time the problem is in the application code, while it does happen it's very unusual to find a bug a library.

Quote
~5 ko/s.

?  1000 ohms per second?

Where are you putting all this data?

Quote
add a "delay(1);" at the end, before the while loop ... loops,

We're not clairvoyant, how about you post all the code?

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

simkard

For now i'm working on a HTTP server with far more features than webduino that lacks a lot (for me, at least ;)) of features.

When my code captures the client HTTP REQUEST, it has to answer to it after interpreting the contents.
When this is all done, it gathers the file to serve and send the HTTP HEADERS related to this file (content-length ; content-type; etc ...)

While the code serves the file, it stops @ some random file-size but systematically the same repectively for each file.

The code is exactly the one i provided (for the part where i serves the file).
There is no (upper in the code) while loops or anything that could do some timeout on the request.

So, i don't understand why it is just happening !

I will try to do the same without the whole code for trying the behavior.


I'll get back soon ...

CrossRoads

Which SD library are you using?

http://code.google.com/p/sdfatlib/

This one, or something else?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

simkard


Which SD library are you using?

http://code.google.com/p/sdfatlib/

This one, or something else?


The one included in Arduino's IDE 0022 and 0023, souldn't i ?  :smiley-roll-blue:

CrossRoads

Try the other one than. 

BillG does a lot of work maintaining it.

http://code.google.com/u/110949153210107887426/
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Go Up