2019년 3월 25일 월요일

[Linux] How to Control RTC Alarm ( linux & android)

How to Control RTC Alarm at  #linux  /  #android

1. Using sysfc

1.1 Once Scheduled
$ sudo bash -c "echo $(date +'%s' -d '20 minutes') > /sys/class/rtc/rtc0/wakealarm"
$ cat /proc/driver/rtc
rtc_time        : 13:25:55
rtc_date        : 2013-01-07
alrm_time       : 19:45:54
alrm_date       : 2013-01-07
alarm_IRQ       : yes          # Alarm is now on
alrm_pending    : no

1.2 Disable Alarm
$ sudo bash -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"
$ cat /proc/driver/rtc
rtc_time        : 13:28:09
rtc_date        : 2013-01-07
alrm_time       : 13:33:07
alrm_date       : 2013-01-07
alarm_IRQ       : no          # Alarm is now off
alrm_pending    : no

2. Using  #android   Alarm Service

Path : ./frameworks/base/services/java/com/android/server/AlarmManagerService.java

 880                     if ((result & RTC_WAKEUP_MASK) != 0)
 881                         triggerAlarmsLocked(mRtcWakeupAlarms, triggerList, nowRTC);

3. Using  #kernel   alarm device driver
Path : kernel/drivers/rtc/alarm.c

static int alarm_suspend(struct platform_device *pdev, pm_message_t state)

/* CREW - R306 do not need rtc alarm in suspend */
#ifdef CONFIG_MACH_RK3066_R306
rtc_alarm.enabled = 0;
#else
rtc_alarm.enabled = 1;
#endif

댓글 없음:

댓글 쓰기