View Single Post
Old 06-30-2017, 09:56 AM   #18
Bluescreen
Member
Bluescreen began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Feb 2010
Device: Kindle Paperwhite 2
Quote:
Originally Posted by knc1 View Post
What model of Kindle is device: "None Yet"?
Ok, I will update my profile. :-)
But I had written in my first post, it is a PW2 with firmware 5.8.9.2 jailbreaked via serial.
Quote:
Originally Posted by knc1 View Post
There is one of me and over a 1/4 million members registered here.
You gotta give me a break, I can't remember what model Kindle everyone has.
I thought you have a brain the size of a planet

I added some debug output to a file now. So here is my test script:
Code:
RTC=0
LOGGING=1
LOGFILE=/tmp/rtctest.log

currentTime () {
  date +%s
}

##############################################################################
# Logs a message to a log file (or to console if argument is /dev/stdout)
logger () {
  MSG=$1

  # do nothing if logging is not enabled
  if [ "x1" != "x$LOGGING" ]; then
    return
  fi

  #if no logfile is specified, set a default
  if [ -z $LOGFILE ]; then
    $LOGFILE=stdout
  fi

  echo `date`: $MSG >> $LOGFILE
}

##############################################################################
# Wait some time using RTC for wakeup

wait_for () {
  # calculate the time we should return
  ENDWAIT=$(( $(currentTime) + $1 ))

  # disable/reset current alarm
  echo 0 > /sys/class/rtc/rtc$RTC/wakealarm

  # set new alarm
  logger "Current time is $(currentTime)"
  logger "Setting Waketime to $ENDWAIT"
  echo $ENDWAIT > /sys/class/rtc/rtc$RTC/wakealarm

  # check whether we could set the alarm successfully
  if [ $ENDWAIT -eq `cat /sys/class/rtc/rtc$RTC/wakealarm` ]; then
    logger "Waketime set correctly"
    # wait for timeout to expire
    while [ $(currentTime) -lt $ENDWAIT ]; do
      REMAININGWAITTIME=$(( $ENDWAIT - $(currentTime) ))
      if [ 0 -lt $REMAININGWAITTIME ]; then
        logger "Waiting remaining $REMAININGWAITTIME seconds"
        # wait for device to resume from sleep, or for time out
        lipc-wait-event -s $REMAININGWAITTIME com.lab126.powerd resuming || true
      fi
    done
  else
    logger "Failure setting alarm on rtc$RTC, wanted $ENDWAIT, got `cat /sys/class/rtc/rtc$RTC/wakealarm`"
  fi

  # not sure whether this is required
  # the following throws an error, so I commented it
  #  lipc-set-prop com.lab126.powerd -i deferSuspend 1
}

# wait 2 hours and then wake up
echo "RTCTEST started"
logger "RTCTEST started"
while [ 1 -eq 1 ]; do
  wait_for 900
  echo "Good morning"
  logger "Good morning"
done
And here is the resulting logfile

Code:
Fri Jun 30 08:19:53 UTC 2017: RTCTEST started
Fri Jun 30 08:19:53 UTC 2017: Current time is 1498810793
Fri Jun 30 08:19:53 UTC 2017: Setting Waketime to 1498811693
Fri Jun 30 08:19:53 UTC 2017: Waketime set correctly
Fri Jun 30 08:19:53 UTC 2017: Waiting remaining 900 seconds
Fri Jun 30 13:42:56 UTC 2017: Good morning
Fri Jun 30 13:42:57 UTC 2017: Current time is 1498830176
Fri Jun 30 13:42:57 UTC 2017: Setting Waketime to 1498831076
Fri Jun 30 13:42:57 UTC 2017: Waketime set correctly
Fri Jun 30 13:42:57 UTC 2017: Waiting remaining 899 seconds
You see the device does not wake up. Only after I switch on the kindle at 13:42 it continues the script.
Bluescreen is offline   Reply With Quote