Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
Thread::wait limited to 65 seconds?
Didn't see this before in other forum questions, but, I've got a program that does a Thread::wait(). All is good until I do waits using Thread::wait(milliToWait) where milliToWait > 65000. All the waits with higher numbers seem to come back after 65-67 seconds.
I've gotten around this by breaking them down to 30 second chunks but...
Is this a known issue, or am I using it wrong?
Tony
Using this on an lpc4088. Included libraries are mbed, mbed-rtos, ethernetinterface, and http://developer.mbed.org/users/donatien/code/NTPClient/
Test code is:
- include "mbed.h"
- include "EthernetInterface.h"
- include "NTPClient.h"
- include <stdio.h>
static EthernetInterface eth; static NTPClient ntp;
int main(void) { printf("Start\r\n"); time_t ctTime; ctTime = time(NULL); printf("Time is now (UTC) %s\r\n", ctime(&ctTime)); if (eth.init()) { printf("Error with initing the Ethernet Interface\r\n"); return 0; } else { printf("Ethernet interface was inited!\r\n"); if (eth.connect(30000)) { printf("Error with connecting.\r\n"); return 0; } else { printf("Ethernet interface was connected (brought up)!\r\n"); printf("MAC address %s\r\n", eth.getMACAddress()); printf("IP address %s\r\n", eth.getIPAddress()); if (ntp.setTime("0.pool.ntp.org") == 0) { printf("Successfully set time\r\n"); time_t t = time(NULL); printf("Time is now (UTC) %s\r\n", ctime(&ctTime)); int i; for (i = 4;i<10;i++) { int k = i*10; time_t t = time(NULL); printf("Time before sleep of %d seconds: %s\r\n",k,ctime(&t)); Thread::wait(k * 1000); t = time(NULL); printf("Time AFTER sleep: %s\r\n",ctime(&t)); } } else { printf("Unable to set time. Init failed\r\n"); return 0; } } } printf("End\r\n"); return 1; }
Output from the above program: Start Time is now (UTC) Mon Oct 27 22:06:14 2014
Ethernet interface was inited! Ethernet interface was connected (brought up)! MAC address 00:04:a3:ab:d1:c3 IP address 10.125.140.88 Successfully set time Time is now (UTC) Mon Oct 27 22:06:14 2014
Time before sleep of 40 seconds: Mon Oct 27 22:06:20 2014
Time AFTER sleep: Mon Oct 27 22:07:00 2014
Time before sleep of 50 seconds: Mon Oct 27 22:07:00 2014
Time AFTER sleep: Mon Oct 27 22:07:50 2014
Time before sleep of 60 seconds: Mon Oct 27 22:07:50 2014
Time AFTER sleep: Mon Oct 27 22:08:50 2014
Time before sleep of 70 seconds: Mon Oct 27 22:08:50 2014
Time AFTER sleep: Mon Oct 27 22:09:55 2014
Time before sleep of 80 seconds: Mon Oct 27 22:09:56 2014
Time AFTER sleep: Mon Oct 27 22:11:01 2014
Time before sleep of 90 seconds: Mon Oct 27 22:11:01 2014
Time AFTER sleep: Mon Oct 27 22:12:07 2014
End
1 Answer
8 years, 11 months ago.
Hey,
my RTOS project also has the same problem. All waitings over 60 sec were ignored...
Whats your workaround?
thanks