View previous topic :: View next topic |
Author |
Message |
schitthoch3 Tux's lil' helper
Joined: 22 Mar 2004 Posts: 94
|
Posted: Sun Dec 06, 2009 4:16 pm Post subject: SOLVED mythwelcome acpi wakeup /sys/class/rtc/rtc0/wakealarm |
|
|
Hi all.
I have to change my acpi wakeup from the old /proc/acpi/alarm to the new /sys/class/rtc/rtc0/wakealarm interface.
I am using mythtv (mythwelcome) to set the alarm time.
I am trying to follow the MythTV Wiki to set up my system. But the autors seem to have mixed different setups (e.g. old interface, using epoch, or others, using utc or localtime). therefore i believe the wiki is not really consistent.
My PC is running UTC in BIOS.
Wakeup works when i test it manually with:
Code: |
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
|
So it works when i write wakeup time in epoch. But it does not work in mythtv using time_t as input parameter to the following script:
Code: |
#!/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
echo 0 > /sys/class/rtc/rtc0/wakealarm #this clears your alarm.
echo $1 > /sys/class/rtc/rtc0/wakealarm #this writes your alarm
|
I believe that mythtv now gives the time_t argument in localtime. This is processed in the script, but apparently i need it to be converted in UTC before writing it to the rtc.
How would i do that ...?
Additionally i don't know if mythtv really gives the wakeup time in epoch (time_t) as i can take from the log:
Quote: |
2009-12-06 16:55:43.464 Running the command to set the next scheduled wakeup time :-
sudo /usr/local/bin/MythWakeSet 17:15 2009-12-06
2009-12-06 16:55:43.497 Running the command to shutdown this computer :-
sudo mythshutdown --shutdown
|
17:15 2009-12-06 seems not to be time_t but i set it explicitely in mythtv-setup
Last edited by schitthoch3 on Tue Jan 12, 2010 3:06 pm; edited 1 time in total |
|
Back to top |
|
|
Chris W l33t
Joined: 25 Jun 2002 Posts: 972 Location: Brisbane, Australia
|
Posted: Mon Dec 07, 2009 12:57 am Post subject: |
|
|
This is how I do it as a drop-in replacement for nvram-wakeup (MythTV 0.21):
Code: | #!/bin/sh
# $1 is the --settime switch that nvram-wakeup normally expects
# $2 is the date/time in seconds since 1970
UPBY=$2 # desired time to have machine up and running
WAKE=$(( UPBY - 120 )) # two minutes earlier than requested
SECS=$( date -d "1970-01-01 ${WAKE} sec" "+%s" -u )
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm
|
In hindsight the epoch time from MythTV should be a number of seconds since 1970-01-01T00:00:00 UTC regardless of your timezone and not need adjusting for use as-is. (i.e. the "SECS=..." line is unnecessary) _________________ Cheers,
Chris W
"Common sense: The collection of prejudices acquired by age 18." -- Einstein |
|
Back to top |
|
|
schitthoch3 Tux's lil' helper
Joined: 22 Mar 2004 Posts: 94
|
Posted: Tue Jan 12, 2010 3:05 pm Post subject: |
|
|
The Mythtv Wiki has improved a little bit. I have it running. You have to execute the time setting script from mythtv-setup screen, not mythwelcome-settings ...
My adapted settings for my system running in UTC, myself being in a different timezone, autostarting mythwelcome and shutting down automatically after the recording when no mythfrontend is started (Network Client Frontend or same machine)
My systems' settings are:
BIOS set to UTC
kernel: 2.6.31-r6
clock="UTC" in /etc/conf.d/hwclock
clock_systohc="NO" in /etc/conf.d/hwclock
kernel-config
Code: |
# RTC interfaces
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
# Platform RTC drivers
CONFIG_RTC_DRV_CMOS=y
|
mythtv-setup
Power on command: (leave this blank)
Block shutdown: Your Choice / Unchecked
Idle shutdown timeout (secs): 180
Max. wait for recording (min): 15
Startup before rec. (secs): 200 (occasional disk check on boot, make this time long enough to complete the boot & disk check)
Wakeup time format: hh:mm yyyy-MM-dd
Command to set Wakeup Time: sudo /usr/local/bin/MythWakeSet $time
Server halt command: sudo mythshutdown --shutdown
Pre Shutdown check-command: sudo mythshutdown --check
mythwelcome --setup
Command to set wakeup time: (leave this blank)
Wakeup time format: hh:mm yyyy-MM-dd
nvram-wakeup Restart command: (Must be blank)
Command to shutdown: sudo /sbin/shutdown -h now
Command to start the frontend: /usr/bin/mythfrontend
/etc/sudoers
Code: |
Host_Alias LOCAL = MYHOSTNAME, localhost
User_Alias MULTIMEDIANS = MYUSER (the ones running mythtv-backend / frontend)
Cmnd_Alias SHUTDOWN = /sbin/shutdown, /sbin/reboot, /sbin/halt, /usr/local/bin/MythWakeSet, /usr/bin/mythshutdown,
Defaults env_reset
# User privilege specification
root ALL=(ALL) ALL
MULTIMEDIANS LOCAL=(ALL) NOPASSWD: SHUTDOWN
MULTIMEDIANS LOCAL=(ALL) NOPASSWD: LOG
|
/usr/local/bin/MythWakeSet
Code: |
#!/bin/sh
# inspired from http://www.mythtv.org/wiki/index.php/ACPI_Wakeup
# and https://help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake
# set mythtv wake-up time with UTC-adjusted time
# use: MythWakeSet date time
# ex.: MythWakeSet 2008-11-02 20:15:00
# See also 'man date' for date/time-formats.
TZ=$(date +%z)
LOG=/var/log/mythtv/mythbackend.log
DATE=$(date -d "$1 $2 $TZ" "+%F %H:%M:%S" -u)
SECS=$(date -d "$1 $2" "+%s")
echo Running $0 to set the wakeup time to $1 $2 >>$LOG
if [ -e /sys/class/rtc/rtc0/wakealarm ]; then
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm
echo "echo 0 > /sys/class/rtc/rtc0/wakealarm" >>$LOG
echo "echo $SECS > /sys/class/rtc/rtc0/wakealarm" >>$LOG
cat /proc/driver/rtc >>$LOG
else
if [ -e /proc/acpi/alarm ]; then
echo $DATE > /proc/acpi/alarm
echo "echo $DATE > /proc/acpi/alarm" >>$LOG
else
echo "ERROR, Wakeup not set, no /sys/class/rtc/rtc0/wakealarm and no /proc/acpi/alarm found" >>$LOG
fi
fi
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|