Pages: [1]   Go Down
Author Topic: maximum time spent in while loop ?  (Read 570 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27361
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you do anything to explicitly turn the watchdog on?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 25, 2011, 05:08:14 am by simkard » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
« Last Edit: November 25, 2011, 05:25:27 am by simkard » Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8600
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For now i'm working on a HTTP server with far more features than webduino that lacks a lot (for me, at least smiley-wink) 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 ...
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27361
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Which SD library are you using?

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

This one, or something else?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27361
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try the other one than. 

BillG does a lot of work maintaining it.

http://code.google.com/u/110949153210107887426/
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll give it a shot ...
Logged

Pages: [1]   Go Up
Jump to: