View Single Post
Old 03-15-2014, 12:56 PM   #9
peterson
Connoisseur
peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.
 
Posts: 74
Karma: 889004
Join Date: Mar 2014
Device: Kindle PW2
I did some digging, googling and minor head scratching, and I believe it is possible to wake up a device at a specific time.

The Kindle's processor has a RTC (real time clock) that can be accessed via /sys/class/rtc/rtc0. There's also rtc1 and rtc2.

I wrote the following small script:

Code:
TS=`date +%s`
TS=$(($TS + 200))

for i in 0 1 2; do
        echo 0 > /sys/class/rtc/rtc$i/wakealarm
        echo $TS > /sys/class/rtc/rtc$i/wakealarm

        if test $TS -ne `cat /sys/class/rtc/rtc$i/wakealarm`; then
                echo "Failure setting alarm on rtc$i, wanted $TS, got `cat /sys/class/rtc/rtc$i/wakealarm`"
        else
                echo "Success on rtc$i"
        fi
done

while test $TS -gt `date +%s`; do
        sleep 1   
done

date >> /tmp/alarmlog
and run it via "./test.sh &". Then I unplugged the cable (screen saver was active). From previous tests I know that the device goes to suspend after roughly 120 seconds. So I waited 7 minutes and turned the device back on.

In dmesg I can see that after I unplugged the cable the Kindle would suspend. Then it woke up and a minute later went back to sleep. It woke up again when I plugged the cable back in. /tmp/alarmlog shows a date-time which is 206 seconds after I issued the command.

I will have to do more tests, mainly to see which rtc is safe to use (wouldn't want to overwrite an alarm by the Kindle OS). Also how long the device wakes up, it may be that one has to trigger some action to prevent it going back to sleep too soon.
peterson is offline   Reply With Quote