Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes Linux RTC alarm use relative or absolute time?
    text
    copied!<p>I'm trying to configure RTC alarm on a Linux device. I've used an example from the <a href="https://www.kernel.org/doc/Documentation/rtc.txt" rel="nofollow">RTC documentation</a>:</p> <pre><code> int retval struct rtc_time rtc_tm; /* .... */ /* Read the RTC time/date */ retval = ioctl(fd, RTC_RD_TIME, &amp;rtc_tm); if (retval == -1) { exit(errno); } /* Set the alarm to 5 sec in the future, and check for rollover */ rtc_tm.tm_sec += 5; if (rtc_tm.tm_sec &gt;= 60) { rtc_tm.tm_sec %= 60; rtc_tm.tm_min++; } if (rtc_tm.tm_min == 60) { rtc_tm.tm_min = 0; rtc_tm.tm_hour++; } if (rtc_tm.tm_hour == 24) rtc_tm.tm_hour = 0; retval = ioctl(fd, RTC_ALM_SET, &amp;rtc_tm); if (retval == -1) { exit(errno); } </code></pre> <p>This code snippet uses absolute time (from the epoch start) and it did not work for me. I thought this was due to a bug in hardware, but after some seemingly random time the alarm did fire. The only other piece of documentation that I've managed to find was a comment in <a href="http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/drivers/char/rtc.c#L491" rel="nofollow">rtc.cc</a>:</p> <pre><code> case RTC_ALM_SET: /* Store a time into the alarm */ { /* * This expects a struct rtc_time. Writing 0xff means * "don't care" or "match all". Only the tm_hour, * tm_min and tm_sec are used. */ </code></pre> <p>The fact that only hours, minutes and second are used suggests that time is relative to the moment when ioctl was called.</p> <p>Should time passed to ioctl(fd, RTC_ALM_SET, &amp;rtc_tm) be relative or absolute?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload