Jump to content
OMRON Forums

clock_gettime( ) interval wrong


Recommended Posts

I've just proven that the .tv_sec field of a increments by *10* every second on a PPMAC. Here's the code:


struct timespec itval;

itval.tv_sec = 42; // Just to verify value is being loaded.

while (1)


if (clock_gettime(CLOCK_REALTIME, &itval) < 0)

fprintf(stderr, "clock_gettime() barfed, code %d.\n", errno);


fprintf(stderr, "itval.tv_sec = %ul.\n", itval.tv_sec);




Both the range of the number (only a few hundred thousand - no even close to the 1970 epoch) and interval (10) are wrong? What's going on here? Has Xenomai monkeyd around with clock_gettime()?

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Wait - - interval looks wrong due simply to using "%ul" instead of "%lu" in the format statement. So the lower-case 'l' suffix looks like an extra '1' digit, suggestings a number an order of magnitude larger. Oops. Our system fixed fonts are also partly to blame.


OK, so that accounts for the interval. Good.


Now what about the offset value, though. Why a "realtime" value of only ~22,000?

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...