sysfs
Interface
The sysfs
interface can be used to read and set the status of RTC.
The interface only supports setting on the following two parameters:
- wakealarm: Run the following command to set a wakeup
alarm in X seconds since the current RTC time.
echo ‘+X’ > /sys/class/rtc/rtc0/wakealarm
Note:- The interface is Linux original and the alarm is set in seconds. For
example, to set an alarm which rings after 2 hours, use the
following command:
echo ‘+7200’ > /sys/class/rtc/rtc0/wakealarm
- The minimum alarms unit supported by the RTC alarm register is in
minutes. If it is less than 1 minute, the next minute is used as the
alarm time. For example, if the current time is 09 : 00 : 45, the
example command should
be:
So, the time to trigger alarm should be 09 : 02 : 00.echo ‘+30’ > /sys/class/rtc/rtc0/wakealarm
- The interface is Linux original and the alarm is set in seconds. For
example, to set an alarm which rings after 2 hours, use the
following command:
- offset: Used to calibrate the time offset caused by temperature and oscillator. Not recommended to use in the current product release.
The following code block shows a simple example.
# cd /sys/class/rtc/rtcO/
# ls
alarmtimer.0.auto hctosys range uevent
date max_user_freq since_epoch wakealarm
dev name subsystem
device offset time
# cat date
2001-02-01
# cat time
00:23:57