Go Down

Topic: Ethernet WebclientRepeating sample - postingInterval (Read 2557 times) previous topic - next topic


In the WebClientRepeating sample code for the Ethernet library there is a line for determining the posting interval.   The line is

Code: [Select]
const unsigned long postingInterval = 60*1000;  // delay between updates, in milliseconds

The problem is the actual value of the postingInterval is wrong when I print it out. It seems to be a casting/overflow problem with the compiler/preprocessor.
I broke this out into very short sample code to demonstrate:

Code: [Select]
const unsigned long postingInterval = 60*1000;
const unsigned long postingIntervalB = (long)60*1000;

void setup() {

void loop() {}

When I run this I get back the following values:
Code: [Select]

The first value is obviously incorrect while the second one is fine.   What bothers me is this was happening in the Ethernet library sample code and the httprequest function was never called because of such a high postingInterval value.

Has this been posted before and I just didn't see it in the forum (I got back a ton of unrelated results when searching). Or is something weird going on with my three Arduino installs?


Hadn't noticed that before, but it seems you are correct. I got the same results using the multiplication. If I assigned it this way, it is fine.
Code: [Select]
unsigned long postingInterval = 60000;
// or this way
unsigned long postingInterval = 60ul * 1000ul;


it appears that one other person had the same problem on the forum  http://arduino.cc/forum/index.php/topic,116279.0.html

They never got the code to work and it appears he had the same problem I had.   It never actually sent data because the postingInterval is much larger than 60000.   

Um... I suppose I should report this... somewhere.   :smiley-roll-blue:

Go Up