Pages: [1]   Go Down
Author Topic: UDP receiving packets inside TImer Routine  (Read 478 times)
0 Members and 1 Guest are viewing this topic.
Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

G'Day all,

I am trying to use a 10second timer routine to issue an NTP request and then check 10seconds later for a received packet and process it.

I want to sned the request and check in the same timer routine which I will expand out later. If the packet has been received I then flag for a resend on the next timer function call.

However the code hangs after the first tx of the NTP packet! Does UDP calls work inside a simple timer routine?

Sid
Logged


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

Quote
Does UDP calls work inside a simple timer routine?
Yes.

edit: Conditionally on your code and hardware, but since you shared neither with us, it is difficult to tell. If you have a memory card in the microSD slot, remove it for the test. How does the UdpNtpClient code in the ethernet examples work?

« Last Edit: August 28, 2012, 06:15:07 am by SurferTim » Logged

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

More info....
  • IDE is v1.0
  • board is standard Duemilanova
  • code is NTP demo code which works fine outside of timer routine
  • Timer library is MSTimer2 from Aduino web site
  • Enternet board is off the shelf Wiznet with NO SD fitted
Update:

I left the code running overnight with the UDP code commented out and a 1second timer tick, lots of serial debugging, code is ticking over every second. To reduce SRAM usage comments are using the Serial.println(F("comment")); so I cant see a RAM issue. Timer code works with no perceived issues.

NTP code works fine outside of timer routine as per NTP example, but I'm trying to schedule stuff to do based on fixed time quantums so running full speed in a loop is not ideal for the task at hand, I might change the logic to use the timer solely as a counter and then simple state logic to send UDP requests and monitor receives outside of the timer ISR and inside loop().

Any thoughts on issues that might arise are welcome, I'll Keep you updated.

Logged


Leeds, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is teh timer routine you refer to an interupt? I just wondered as receiving an ethnet packet presumably uses an interupt, and therefore are you trying to interupt during an interupt which doesn't work and just loses everything?

Only a suggestion/guess as I  have seen references to not using serial print commands in interupt routines.

Paul
Logged

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

IDE v1.0 had a bug in the ethernet library that caused problems. May I suggest upgrading to v1.0.1.

BTW, the ethernet library does not use an interrupt. It is a polling type device.
Logged

Pages: [1]   Go Up
Jump to: