Hi<div><br></div><div>I have a problem in setting up ACPI WakeUp on my MythTv BE/FE on Ubuntu 10.10</div><div>It's a log time I'm trying to setting it up correctly but I gave up several times.</div><div>Now I've discovered that I made a small but important error, by setting up in mythtv-setup the time format in:</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="'courier new', monospace">'yyyy-MMddThh:mm:ss'</font></div></blockquote><div>instead than</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><font face="'courier new', monospace">'yyyy-MM-ddThh:mm:ss'</font></div></blockquote><div>So, previously the Mythwelcome screen shows countdown but, when it reached to 0, it restarted, because of the check of time format.</div>
<div><br></div><div>Now, after correcting the error, MythWelcome shuts down. But it doesn't wake up.</div><div>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.</div>
<div><br></div><div>First of all: I've setted up my sistem following both:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="http://www.mythtv.org/wiki/ACPI_Wakeup">http://www.mythtv.org/wiki/ACPI_Wakeup</a></div>
</blockquote><div>and</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="http://www.mythtv.org/wiki/Mythwelcome">http://www.mythtv.org/wiki/Mythwelcome</a></div></blockquote><div><br></div><div>
<b>ACPI WAKEUP SETTINGS</b></div><div>Follwing:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="http://www.mythtv.org/wiki/ACPI_Wakeup">http://www.mythtv.org/wiki/ACPI_Wakeup</a>:</div></blockquote>
<div><br></div><div>My system can wake up from S4:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ grep -i rtc /var/log/kern.log</font></div></div>
<div><div><font face="'courier new', monospace">Feb 12 14:12:56 multisala kernel: [ 0.787284] rtc_cmos 00:03: RTC can wake from S4</font></div></div></blockquote><div><br></div><div>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</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ cat /etc/default/rcS |grep HWCLOCKACCESS</font></div></div><div><div><font face="'courier new', monospace">HWCLOCKACCESS=no</font></div>
</div></blockquote><div><br></div><div>and for the Ubuntu 9.10 and later by commenting out "exec" line in the proper file</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ cat /etc/init/hwclock-save.conf |grep exec</font></div>
</div><div><div><font face="'courier new', monospace"># exec hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear</font></div></div></blockquote><div><br></div><div>kernel is newer than 2.6.22</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><div><font face="'courier new', monospace">$ uname -a</font></div></div><div><div><font face="'courier new', monospace">Linux multisala 2.6.35-32-generic #65-Ubuntu SMP Tue Jan 24 13:48:14 UTC 2012 i686 GNU/Linux</font></div>
</div></blockquote><div><br></div><div>so it use /sys/class/rtc/rtc0/wakealarm</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ ls /sys/class/rtc/rtc0/wakealarm</font></div>
</div><div><div><font face="'courier new', monospace">/sys/class/rtc/rtc0/wakealarm</font></div></div></blockquote><div>consequentiely, wakealarm should accept time format in epoch time</div><div><br></div><div><b>TESTING</b></div>
<div>Now, it's time to test it by following</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm">http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm</a></div>
</blockquote><div><br></div><div>$ sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"</div><div>$ sudo sh -c "echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm"</div>
<div>$ cat /sys/class/rtc/rtc0/wakealarm</div><div><div>$ cat /proc/driver/rtc</div><div>rtc_time : 15:45:14</div><div>rtc_date : 2012-02-12</div><div>alrm_time : 15:50:06</div><div>alrm_date : ****-**-12</div>
</div><div><br></div><div><u>PROBLEM!</u></div><div>date is</div><div>****-**-12</div><div><br></div><div>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.</div>
<div><br></div><div><b>SECOND TEST</b></div><div>still according to</div><div><a href="http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm">http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm</a> (Example to convert to epoch time and set date/time)</div>
<div>I've tried to make a further test by:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ echo 0 > /sys/class/rtc/rtc0/wakealarm</font></div>
</div><div><div><font face="'courier new', monospace">-bash: /sys/class/rtc/rtc0/wakealarm: Permission denied</font></div></div></blockquote><div><br></div><div>It looks like I don't have permission to do that. Let's try with sudo:</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ sudo echo 0 > /sys/class/rtc/rtc0/wakealarm</font></div></div><div><div><font face="'courier new', monospace">-bash: /sys/class/rtc/rtc0/wakealarm: Permission denied</font></div>
</div></blockquote><div><br></div><div>still no permission! let's root:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="'courier new', monospace">$ sudo su</font></div>
<div><font face="'courier new', monospace">$ echo 0 > /sys/class/rtc/rtc0/wakealarm</font></div><div><font face="'courier new', monospace">$ date -u --date "Feb 12, 2012 16:00:00" +%s > /sys/class/rtc/rtc0/wakealarm</font></div>
<div><font face="'courier new', monospace">$ cat /proc/driver/rtc</font></div><div><div><font face="'courier new', monospace">rtc_time : 15:50:12</font></div></div><div><div><font face="'courier new', monospace">rtc_date : 2012-02-12</font></div>
</div><div><div><font face="'courier new', monospace">alrm_time : 16:00:00</font></div></div><div><div><font face="'courier new', monospace">alrm_date : 2012-02-12</font></div></div></blockquote>
<div><br></div><div>I've got it! Time is now setted up and, if I do a</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="'courier new', monospace">sudo shutdown -P now</font></div>
</blockquote><div><br></div><div>My BE/FE shuts down and wake up at 16:00:00 UTC time (15:00:00 local time)</div><div><br></div><div>Now: reading the next paragraph (Setting alarm when BIOS clock is in localtime)</div><div>
I've learned that "The BIOS clock is in localtime, however wakealarm must be given a UTC time"</div><div>But my BIOS *SHOULD BE* in UTC time, because of the difference between date result and BIOS query:</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ date</font></div></div><div><div><font face="'courier new', monospace">Sun Feb 12 14:58:17 CET 2012</font></div>
</div><div><div><font face="'courier new', monospace">$ cat /proc/driver/rtc</font></div></div><div><div><font face="'courier new', monospace">rtc_time : 15:58:20</font></div></div></blockquote><div>
<br></div><div>By the way: let's go with next check as suggested in Wiki:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="'courier new', monospace">$ SECS=`date -u --date "2012-01-12 17:00:00" +%s`</font></div>
<div><div><font face="'courier new', monospace">$ echo 0 > /sys/class/rtc/rtc0/wakealarm</font></div></div><div><div><font face="'courier new', monospace">-bash: /sys/class/rtc/rtc0/wakealarm: Permission denied</font></div>
</div></blockquote><div><br></div><div>Whoops, I'm not a sudoers? (but the setwakeup.sh script is, see later). Anyway, let's sudo:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><font face="'courier new', monospace">$ sudo su</font></div><div><font face="'courier new', monospace">$ SECS=`date -u --date "2012-02-12 17:00:00" +%s`</font></div><div><div><font face="'courier new', monospace">$ echo 0 > /sys/class/rtc/rtc0/wakealarm</font></div>
</div><div><div><font face="'courier new', monospace">$ echo $SECS > /sys/class/rtc/rtc0/wakealarm</font></div></div><div><div><font face="'courier new', monospace">$ cat /proc/driver/rtc</font></div></div>
<div><div><font face="'courier new', monospace">rtc_time : 16:08:32</font></div></div><div><div><font face="'courier new', monospace">rtc_date : 2012-02-12</font></div></div><div><div><font face="'courier new', monospace">alrm_time : 17:00:00</font></div>
</div><div><div><font face="'courier new', monospace">alrm_date : 2012-02-12</font></div></div></blockquote><div><br></div><div>Double-check: let's face the "sudo" problem, by going directly to the setwakeup.sh, to clean any doubt on the permission thing:</div>
<div><br></div><div><div>$ time=`date -u --date "2012-02-12 18:00:00" +%s`</div><div>$ sudo sh -c "/usr/bin/setwakeup.sh $time"</div><div>$ cat /proc/driver/rtc</div><div>rtc_time : 16:12:36</div>
<div>rtc_date : 2012-02-12</div><div>alrm_time : 18:00:00</div><div>alrm_date : 2012-02-12</div></div><div><br></div><div>So: all checks are checked out.</div><div><br></div><div><b>INTEGRATE INTO MYTHTV</b></div>
<div><br></div><div>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:</div><div><br></div><div>
I use MythWelcome, so - despite the fact I've read all the Wiki page - I'll skip to "Mythwelcome users" paragraph.</div><div>I see two settings related to my problem:</div><div><br></div><div><div>mythbackend Shutdown/Wakeup Options (mythtv-setup)</div>
</div><div><br></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">Wakeup time format : yyyy-MM-ddThh:mm:ss (Must be this format for mythshutdown)</font></div>
</div></blockquote><div><div></div></div><div><br></div><div>that's it (I miss "T" meanings, but I'm just RTFMing)</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>
<span style="font-family:'courier new',monospace">Command to set Wakeup Time : mythshutdown --setwakeup $time</span></div></div></blockquote><div><br></div><div>all checked. </div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><i>BEGIN NOTE:</i></div><div><i>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:</i></div><div><i><br></i></div>
<div><i>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)</i></div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><i>mysql> SELECT value, data FROM settings where hostname ='multisala' and data like '%yyyy%' order by value;</i></div></div>
</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><i>+-----------------------+------------------+</i></div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><div><div><i>| value | data |</i></div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><i>+-----------------------+------------------+</i></div>
</div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><i>| MythWelcomeDateFormat | dddd</i></div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><div><div><i>dd MMM yyyy |</i></div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><i>+-----------------------+------------------+</i></div></div></div></blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><i>1 row in set (0.00 sec)</i></div></div></div></blockquote><div><div><i><br></i></div></div><div><div><i>for the Command to set Wakeup time, no data corresponding to what I've just set up:</i></div>
</div><div><div><i><br></i></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace"><i>mysql> SELECT value, data FROM settings where hostname ='multisala' and data like '%mythshutdown%' order by value;</i></font></div>
</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace"><i>Empty set (0.00 sec)</i></font></div></div></blockquote><div><i><br></i></div><div>
<i>END NOTE;</i></div></blockquote><div><br></div><div><div>MythShutdown/MythWelcome Settings (mythwelcome --setup or F11 in mythwelcome)</div></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><div><font face="'courier new', monospace">Command to set wakeup time : sudo /usr/bin/setwakeup.sh $time</font></div></div><div><div><font face="'courier new', monospace">Wakeup time format : time_t</font></div>
</div><div><div><font face="'courier new', monospace">nvram-wakeup Restart command : (Must be blank)</font></div></div><div><div><font face="'courier new', monospace">Command to shutdown : sudo shutdown -h now (some systems may need "sudo shutdown -P now" </font></div>
</div><div><div><font face="'courier new', monospace"> instead (-h may cause system to restart))</font></div></div><div><div><font face="'courier new', monospace">Command to start the frontend : /usr/bin/mythfrontend</font></div>
</div></blockquote><div><br></div><div>Now i can check them via mysql:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">mysql> SELECT value, data FROM settings where hostname ='multisala' and value like '%shutdown%' order by value;</font></div>
</div><div><div><font face="'courier new', monospace">+-----------------------------+----------------------------------+</font></div></div><div><div><font face="'courier new', monospace">| value | data |</font></div>
</div><div><div><font face="'courier new', monospace">+-----------------------------+----------------------------------+</font></div></div><div><div><font face="'courier new', monospace">| AllowQuitShutdown | 4 |</font></div>
</div><div><div><font face="'courier new', monospace">| MythShutdownNvramCmd | sudo /usr/bin/setwakeup.sh $time |</font></div></div><div><div><font face="'courier new', monospace">| MythShutdownNvramRestartCmd | |</font></div>
</div><div><div><font face="'courier new', monospace">| MythShutdownPowerOff | sudo shutdown -h now |</font></div></div><div><div><font face="'courier new', monospace">| MythShutdownReboot | sudo shutdown -h -r now |</font></div>
</div><div><div><font face="'courier new', monospace">| MythShutdownWakeupTimeFmt | time_t |</font></div></div><div><div><font face="'courier new', monospace">| MythShutdownXTermCmd | xterm |</font></div>
</div><div><div><font face="'courier new', monospace">+-----------------------------+----------------------------------+</font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><div><font face="'courier new', monospace">7 rows in set (0.00 sec)</font></div></div></blockquote><div><br></div><div>the setwakeup.sh script is allright:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><div><font face="'courier new', monospace">$ cat /usr/bin/setwakeup.sh</font></div></div><div><div><font face="'courier new', monospace">#!/bin/sh</font></div></div><div><div><font face="'courier new', monospace">#$1 is the first argument to the script. It is the time in seconds since 1970</font></div>
</div><div><div><font face="'courier new', monospace">#this is defined in mythtv-setup with the time_t argument</font></div></div><div><div><font face="'courier new', monospace"><br></font></div></div><div>
<div><font face="'courier new', monospace"><br></font></div></div><div><div><font face="'courier new', monospace">UTCBIOS=true</font></div></div><div><div><font face="'courier new', monospace"><br>
</font></div></div><div><div><font face="'courier new', monospace">if $UTCBIOS</font></div></div><div><div><font face="'courier new', monospace">then</font></div></div><div><div><font face="'courier new', monospace"> #utc bios - use supplied seconds</font></div>
</div><div><div><font face="'courier new', monospace"> SECS=$1</font></div></div><div><div><font face="'courier new', monospace">else</font></div></div><div><div><font face="'courier new', monospace"> #non utc bios - convert supplied seconds to seconds from</font></div>
</div><div><div><font face="'courier new', monospace"> #epoch to local time</font></div></div><div><div><font face="'courier new', monospace"> SECS=`date -u --date "\`date --date @$1 +%F" "%T\`" +%s`</font></div>
</div><div><div><font face="'courier new', monospace">fi</font></div></div><div><div><font face="'courier new', monospace"><br></font></div></div><div><div><font face="'courier new', monospace">echo 0 > /sys/class/rtc/rtc0/wakealarm #this clears your alarm.</font></div>
</div><div><div><font face="'courier new', monospace">echo $1 > /sys/class/rtc/rtc0/wakealarm #this writes your alarm</font></div></div></blockquote><div><br></div><div>and so /etc/sudoers is:</div><div><br></div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="'courier new', monospace">$ sudo cat /etc/sudoers |grep mythtv</font></div></div><div><div><font face="'courier new', monospace">%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh, /usr/bin/mythshutdown</font></div>
</div></blockquote><div><br></div><div><b>ALL CHECK FINISHED, NOW WHAT?</b></div><div><br></div><div>After all those checks:</div><div>Working:</div><div>- MythWelcome shuts down my BE/FE according to time parameters</div>
<div>Not working:</div><div>- The MythTv BE/FE doesn't wake up</div><div><br></div><div>I was thinking that the problem could be related to</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>the UTC/local time thing</div></blockquote><div>or</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>the time_t/yyyy-MM-dd hh:mm:ss thing</div><div><br></div></blockquote>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.<div>
<br></div><div>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.</div>
<div><br></div><div>If any of you can point me in the right direction, I'll be grateful :)</div>