Openmoko Bug #2156: rtctest.c does not exit with stable-tracking kernel

Openmoko Public Trac bugs at docs.openmoko.org
Wed Dec 3 21:14:15 CET 2008


#2156: rtctest.c does not exit with stable-tracking kernel
-----------------------------+----------------------------------------------
 Reporter:  lindi            |          Owner:  balajirrao 
     Type:  defect           |         Status:  accepted   
 Priority:  normal           |      Milestone:             
Component:  System Software  |        Version:  unspecified
 Severity:  normal           |       Keywords:             
 Haspatch:  0                |      Blockedby:             
Estimated:                   |    Patchreview:             
 Blocking:                   |   Reproducible:             
-----------------------------+----------------------------------------------

Comment(by lindi):

 balajirrao, thanks a lot for your observations. I can have my phone wake
 up from suspend when I use WKALM_SET. With the above code I can now just
 say

 {{{
  rtcwake `date +%s -d "now + 3 hours"` && susp && alarm
 }}}

 to have my phone sleep for 3 hours and then notify me :-)

 rtcwake.c:
 {{{
 #include <stdio.h>
 #include <linux/rtc.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <assert.h>
 #include <time.h>

 int main(int argc, char **argv) {
     int fd, ret;
     struct rtc_wkalrm wkalrm;

     assert(argc == 2);

     fd = open("/dev/rtc0", O_RDONLY);
     assert(fd);

     {
         struct tm *tm;
         time_t secs;

         secs = atol(argv[1]);
         assert(secs > 86400*365*(2000-1970));
         assert(secs < 86400*365*(2030-1970));
         tm = gmtime(&secs);
         assert(tm);

         wkalrm.time.tm_sec = tm->tm_sec;
         wkalrm.time.tm_min = tm->tm_min;
         wkalrm.time.tm_hour = tm->tm_hour;
         wkalrm.time.tm_mday = tm->tm_mday;
         wkalrm.time.tm_mon = tm->tm_mon;
         wkalrm.time.tm_year = tm->tm_year;
         wkalrm.time.tm_wday = tm->tm_wday;
         wkalrm.time.tm_yday = tm->tm_yday;
         wkalrm.time.tm_isdst = tm->tm_isdst;
     }

     wkalrm.enabled = 1;
     ret = ioctl(fd, RTC_WKALM_SET, &wkalrm);
     assert(ret != -1);

     return 0;
 }
 }}}

-- 
Ticket URL: <https://docs.openmoko.org/trac/ticket/2156#comment:7>
docs.openmoko.org <http://docs.openmoko.org/trac/>
openmoko trac


More information about the buglog mailing list