Gentoo Archives: gentoo-user

From: Meino.Cramer@×××.de
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] wakeup from suspend
Date: Mon, 11 Jan 2016 04:09:18
Message-Id: 20160111040902.GA5077@solfire
In Reply to: Re: [gentoo-user] wakeup from suspend by waltdnes@waltdnes.org
1 waltdnes@××××××××.org <waltdnes@××××××××.org> [16-01-11 04:04]:
2 > On Sun, Jan 10, 2016 at 02:55:57PM +0100, Meino.Cramer@×××.de wrote
3 > > Hi,
4 > >
5 > > currently I am experimenting with a new embedded system
6 > > (OrangePI PC). I want to suspend the system to RAM.
7 > > After a period of time the system should wakeup.
8 > >
9 > > The RTC on the board seems to support alarms.
10 > >
11 > > Is there a tool to set the alarm time of an RTC
12 > > from the commandline like hwclock set the RTC
13 > > time itsself?
14 > >
15 > > I couldn't find one (or successfully overlooked it...)
16 > >
17 > > Thank you very much in advance for any help!
18 > > Best regards,
19 > > Meino
20 >
21 > I'm not aware of any utilities. Is it linux, and how good are you at
22 > shell scripts? Two virtual files you'll need to know about are...
23 >
24 > /sys/class/rtc/rtc0/since_epoch
25 > /sys/class/rtc/rtc0/wakealarm
26 >
27 > Note that writing to /sys requires root privileges. Both files are in
28 > seconds since 1970-01-01 00:00:00 UTC. This is the same output that
29 > "date +%s" produces. To test it, run the command...
30 >
31 > date +%s ; cat /sys/class/rtc/rtc0/since_epoch
32 >
33 > Let's say that you want it wake up in 3 minutes (i.e. 180 seconds from
34 > now). You'll have to use either "eval" or backticks. The command
35 > would be...
36 >
37 > #!/bin/bash
38 > echo $(( 180 + `cat /sys/class/rtc/rtc0/since_epoch` )) > /sys/class/rtc/rtc0/wakealarm
39 >
40 > ...and powerdown. It should wake up 3 minutes after you issued the
41 > command.
42 >
43 > How about specifying a future time, you ask? First, we need to know
44 > the input format. The "--date" command uses the format
45 > "MM/DD/YYYY HH:mm:ss" (Month/Day/Year Hour:Minute:Second)
46 > the brackets indicate optional items. To get the seconds since epoch at...
47 >
48 > year 2016
49 > month 01
50 > day 20
51 > hour 23
52 > minute 00
53 > second 00
54 >
55 > the command is...
56 >
57 > date +%s --date="01/20/2016 23:00:00"
58 >
59 > ...which outputs 1453348800
60 >
61 > To set a wakeup alarm for that time...
62 >
63 > date +%s --date="01/20/2016 23:00:00" > /sys/class/rtc/rtc0/wakealarm
64 >
65 > You'll probably want to write a script to accept input from a user or
66 > another program. Beware of UTC offsets and Daylight Saving Time.
67 >
68 > --
69 > Walter Dnes <waltdnes@××××××××.org>
70 > I don't run "desktop environments"; I run useful applications
71 >
72
73 Hi Walter,
74
75 THANKS :) for explanation...I am quite familiar with shell scripting
76 under Unices... :)
77
78 Your mail will help me a lot!
79
80 Best regards,
81 Meino