[mythtv-users] MythTv BE/FE go to sleep but doesn't wake up

ganassa ganassa at gmail.com
Sun Feb 12 14:51:45 UTC 2012


Hi

I have a problem in setting up ACPI WakeUp on my MythTv BE/FE on Ubuntu
10.10
It's a log time I'm trying to setting it up correctly but I gave up several
times.
Now I've discovered that I made a small but important error, by setting up
in mythtv-setup the time format in:

'yyyy-MMddThh:mm:ss'

instead than

'yyyy-MM-ddThh:mm:ss'

So, previously the Mythwelcome screen shows countdown but, when it reached
to 0, it restarted, because of the check of time format.

Now, after correcting the error, MythWelcome shuts down. But it doesn't
wake up.
Because of the several different informations found on the web, I think I
made a mess and now I really need an help to get the work done.

First of all: I've setted up my sistem following both:

http://www.mythtv.org/wiki/ACPI_Wakeup

and

http://www.mythtv.org/wiki/Mythwelcome


*ACPI WAKEUP SETTINGS*
Follwing:

http://www.mythtv.org/wiki/ACPI_Wakeup:


My system can wake up from S4:

$ grep -i rtc /var/log/kern.log
Feb 12 14:12:56 multisala kernel: [    0.787284] rtc_cmos 00:03: RTC can
wake from S4


HWclock updates are disabledm both for the Ubuntu 8.04 version ad earlier
(my Ubuntu came from 8.04 version) by setting up HWCLOCKACCES to "no" in
the proper file

$ cat /etc/default/rcS |grep HWCLOCKACCESS
HWCLOCKACCESS=no


and for the Ubuntu 9.10 and later by commenting out "exec" line in the
proper file

$ cat /etc/init/hwclock-save.conf |grep exec
#    exec hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear


kernel is newer than 2.6.22

$ uname -a
Linux multisala 2.6.35-32-generic #65-Ubuntu SMP Tue Jan 24 13:48:14 UTC
2012 i686 GNU/Linux


so it use /sys/class/rtc/rtc0/wakealarm

$ ls /sys/class/rtc/rtc0/wakealarm
/sys/class/rtc/rtc0/wakealarm

consequentiely, wakealarm should accept time format in epoch time

*TESTING*
Now, it's time to test it by following

http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm


$ sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"
$ sudo sh -c "echo `date '+%s' -d '+ 5 minutes'` >
/sys/class/rtc/rtc0/wakealarm"
$ cat /sys/class/rtc/rtc0/wakealarm
$ cat /proc/driver/rtc
rtc_time        : 15:45:14
rtc_date        : 2012-02-12
alrm_time       : 15:50:06
alrm_date       : ****-**-12

*PROBLEM!*
date is
****-**-12

I've read somewhere that **** somewhere in date means: wakeup time was set
up in the past, and it won't wake up. In fact, it doesn't wake up at all.

*SECOND TEST*
still according to
http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm (Example to
convert to epoch time and set date/time)
I've tried to make a further test by:

$ echo 0 > /sys/class/rtc/rtc0/wakealarm
-bash: /sys/class/rtc/rtc0/wakealarm: Permission denied


It looks like I don't have permission to do that. Let's try with sudo:

$ sudo echo 0 > /sys/class/rtc/rtc0/wakealarm
-bash: /sys/class/rtc/rtc0/wakealarm: Permission denied


still no permission! let's root:

$ sudo su
$ echo 0 > /sys/class/rtc/rtc0/wakealarm
$ date -u --date "Feb 12, 2012 16:00:00" +%s > /sys/class/rtc/rtc0/wakealarm
$ cat /proc/driver/rtc
rtc_time        : 15:50:12
rtc_date        : 2012-02-12
alrm_time       : 16:00:00
alrm_date       : 2012-02-12


I've got it! Time is now setted up and, if I do a

sudo shutdown -P now


My BE/FE shuts down and wake up at 16:00:00 UTC time (15:00:00 local time)

Now: reading the next paragraph (Setting alarm when BIOS clock is in
localtime)
I've learned that "The BIOS clock is in localtime, however wakealarm must
be given a UTC time"
But my BIOS *SHOULD BE* in UTC time, because of the difference between date
result and BIOS query:

$ date
Sun Feb 12 14:58:17 CET 2012
$ cat /proc/driver/rtc
rtc_time        : 15:58:20


By the way: let's go with next check as suggested in Wiki:

$ SECS=`date -u --date "2012-01-12 17:00:00" +%s`
$ echo 0 > /sys/class/rtc/rtc0/wakealarm
-bash: /sys/class/rtc/rtc0/wakealarm: Permission denied


Whoops, I'm not a sudoers? (but the setwakeup.sh script is, see later).
Anyway, let's sudo:

$ sudo su
$ SECS=`date -u --date "2012-02-12 17:00:00" +%s`
$ echo 0 > /sys/class/rtc/rtc0/wakealarm
$ echo $SECS > /sys/class/rtc/rtc0/wakealarm
$ cat /proc/driver/rtc
rtc_time        : 16:08:32
rtc_date        : 2012-02-12
alrm_time       : 17:00:00
alrm_date       : 2012-02-12


Double-check: let's face the "sudo" problem, by going directly to
the setwakeup.sh, to clean any doubt on the permission thing:

$ time=`date -u --date "2012-02-12 18:00:00" +%s`
$ sudo sh -c "/usr/bin/setwakeup.sh $time"
$ cat /proc/driver/rtc
rtc_time        : 16:12:36
rtc_date        : 2012-02-12
alrm_time       : 18:00:00
alrm_date       : 2012-02-12

So: all checks are checked out.

*INTEGRATE INTO MYTHTV*

As seen in the latest check, I've already created the setwakeup.sh script
as suggested in the Wiki, and my mythtv user is a sudoers of it, so let's
integrate it in MythTv:

I use MythWelcome, so - despite the fact I've read all the Wiki page - I'll
skip to "Mythwelcome users" paragraph.
I see two settings related to my problem:

mythbackend Shutdown/Wakeup Options (mythtv-setup)


Wakeup time format                     : yyyy-MM-ddThh:mm:ss (Must be this
format for mythshutdown)


that's it (I miss "T" meanings, but I'm just RTFMing)

Command to set Wakeup Time             : mythshutdown --setwakeup $time


all checked.

*BEGIN NOTE:*
*It would be kind to double-check it by query the "settings" table in the
database, but for un unknown reason it doesn't show up in the database:*
*
*
*for the Wakeup time format thing, it only contains a format related to
MythWelcome (and it doesn't have any relation to the MythWelcome settings,
see below in this post when I'll get to the MythWelcome settings)*

*mysql> SELECT value, data FROM settings where hostname ='multisala' and
data like  '%yyyy%' order by value;*

*+-----------------------+------------------+*

*| value                 | data             |*

*+-----------------------+------------------+*

*| MythWelcomeDateFormat | dddd*

*dd MMM yyyy |*

*+-----------------------+------------------+*

*1 row in set (0.00 sec)*

*
*
*for the Command to set Wakeup time, no data corresponding to what I've
just set up:*
*
*

*mysql> SELECT value, data FROM settings where hostname ='multisala' and
data like  '%mythshutdown%' order by value;*

*Empty set (0.00 sec)*

*
*
*END NOTE;*


MythShutdown/MythWelcome Settings (mythwelcome --setup or F11 in
mythwelcome)

Command to set wakeup time             : sudo /usr/bin/setwakeup.sh $time
Wakeup time format                     : time_t
nvram-wakeup Restart command           : (Must be blank)
Command to shutdown                    : sudo shutdown -h now (some systems
may need "sudo shutdown -P now"
                                         instead (-h may cause system to
restart))
Command to start the frontend          : /usr/bin/mythfrontend


Now i can check them via mysql:

mysql> SELECT value, data FROM settings where hostname ='multisala' and
value like '%shutdown%' order by value;
+-----------------------------+----------------------------------+
| value                       | data                             |
+-----------------------------+----------------------------------+
| AllowQuitShutdown           | 4                                |
| MythShutdownNvramCmd        | sudo /usr/bin/setwakeup.sh $time |
| MythShutdownNvramRestartCmd |                                  |
| MythShutdownPowerOff        | sudo shutdown -h now             |
| MythShutdownReboot          | sudo shutdown -h -r now          |
| MythShutdownWakeupTimeFmt   | time_t                           |
| MythShutdownXTermCmd        | xterm                            |
+-----------------------------+----------------------------------+

7 rows in set (0.00 sec)


the setwakeup.sh script is allright:

$ cat /usr/bin/setwakeup.sh
#!/bin/sh
#$1 is the first argument to the script. It is the time in seconds since
1970
#this is defined in mythtv-setup with the time_t argument


UTCBIOS=true

if $UTCBIOS
then
    #utc bios - use supplied seconds
    SECS=$1
else
    #non utc bios - convert supplied seconds to seconds from
    #epoch to local time
    SECS=`date -u --date "\`date --date @$1 +%F" "%T\`" +%s`
fi

echo 0 > /sys/class/rtc/rtc0/wakealarm #this clears your alarm.
echo $1 > /sys/class/rtc/rtc0/wakealarm #this writes your alarm


and so /etc/sudoers is:

$ sudo cat /etc/sudoers |grep mythtv
%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh,
/usr/bin/mythshutdown


*ALL CHECK FINISHED, NOW WHAT?*

After all those checks:
Working:
- MythWelcome shuts down my BE/FE according to time parameters
Not working:
- The MythTv BE/FE doesn't wake up

I was thinking that the problem could be related to

the UTC/local time thing

or

the time_t/yyyy-MM-dd hh:mm:ss thing

but, after trying to read all the forum posts, mailing list messages, blog
suggestions, Ubuntu documents, MythTv Wikis, now I am in a big mess: I
can't understand where I'm doing wrong things.

I've made several attempt to change parameters (UTC, time formats) but the
test are not so easy (I have to make let the BE shuts down and wait for a
program to check if it wake up, and in the meantime I am using my BE to
record things, so it's a long process with a "production" system ;) ) and
now I'm not sure I've tried all the possible combinations done.

If any of you can point me in the right direction, I'll be grateful :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20120212/d2d878e0/attachment.html 


More information about the mythtv-users mailing list