9 years, 6 months 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:

  1. include "mbed.h"
  2. include "EthernetInterface.h"
  3. include "NTPClient.h"
  4. 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, 4 months ago.

Hey,

my RTOS project also has the same problem. All waitings over 60 sec were ignored...

Whats your workaround?

thanks

Problems solved:

There is an exception handling for if (millisec > 4000000) return 0xFFFE; Max ticks supported: So if there were more than 0xFFFE = 65534 ms, ergo 65 sec-> it is limited...

:(

posted by Tobi Roe 22 Dec 2015