Pages: [1]   Go Down
Author Topic: Ethernet WebclientRepeating sample - postingInterval  (Read 951 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 2
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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:
const unsigned long postingInterval = 60*1000;
const unsigned long postingIntervalB = (long)60*1000;

void setup() {
  Serial.begin(9600);
  Serial.println(postingInterval);
  Serial.println(postingIntervalB); 
}

void loop() {}

When I run this I get back the following values:
Code:
4294961760
60000


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

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5986
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
unsigned long postingInterval = 60000;
// or this way
unsigned long postingInterval = 60ul * 1000ul;
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5986
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know where somewhere is!
http://code.google.com/p/arduino/
Logged

Pages: [1]   Go Up
Jump to: