[mythtv-users] STB off

Daryl McDonald darylangela at gmail.com
Mon Sep 9 17:27:55 UTC 2013


Greetings Mythizens, It seems that since adding the "check_stb" script,
that the stb is turned on when Myth or I turn on the PC, which is a good
thing because as I've read and as my limited experience confirms, The
DCT700 needs to be excited first before responding appropriately to IR. Now
that the system is setup to turn itself on and off, I'm guessing that
another line or so should be added to the "setwakeup.sh" to turn the stb
off as a further power saving factor. Can anyone confirm and or direct in
this endeavor? Below is "check_stb"

#! /bin/bash

# Authored by Evuraan_AT_gmail_DOT_com

# ABSOLUTELY NO WARRANTY, to the extent permitted by
# applicable law.

# YMMV.
# Use at your own risk.


pvr="/dev/video0"
t="$RANDOM-$RANDOM"
out="/tmp/$t.mpg"
mark="1727"
blank="0"
say="/usr/bin/logger -p info -t mythstb-check"
POWEROFF="0"
POWERON="0"
wakeup="/usr/bin/irsend SEND_ONCE DCT700 POWER"
info="/usr/bin/irsend SEND_ONCE DCT700 info"



send_power_on() {
$say "`date` STB seems to be turned off, last count was $blank, attempting
to Power it on" &
$wakeup 1>/dev/null 2>/dev/null || :
sleep 2
}

scan_images(){
for i in `echo /tmp/$t*.jpeg`
do
if [ -s "$i" ]
then
#blank="`jp2a $i --invert --size=72x24 | sed -e 's/./& \n/g'|grep -c "M"`"
blank="`jp2a $i --invert --size=72x24 | sed 's/W/M/g' | sed -e 's/./&
\n/g'|grep -c "M"`"
 rm -f "$i" 1>/dev/null 2>/dev/null || :
else
 :
fi
[ "$blank" -gt "$mark" ] && export POWERON="100"
[ "$blank" -le "$mark" ] && export POWEROFF="100"
done
if [ "$POWERON" -eq "100" -a "$POWEROFF" -ne "100" ]
then
# its off
send_power_on
else
# power is on, non blank frames
$say "`date` STB seems to be turned on, last count was $blank"
:
fi

}

purge_stuff(){
[ -f "$out" ] && rm -f "$out" 1>/dev/null >/dev/null || :
}

#ivtv-tune -c 3 -d "$pvr" 1>/dev/null 2>/dev/null &

cd /tmp
$info &

dd if="$pvr" of="$out" bs=64K count=2  1>/dev/null 2>/dev/null

if [ -s "$out" ]
then
ffmpeg -i $out -f image2 -vcodec mjpeg /tmp/$t%d.jpeg 1>/dev/null
2>/dev/null
[ -s "/tmp/${t}1.jpeg" ] && scan_images
else
$say "`date` Unable to query $pvr, as it seems to be in use."
:
fi

purge_stuff &

And here is the "setwakeup.sh"

#!/bin/sh
#
# set ACPI Wakeup time
# usage: setwakeup.sh seconds
#    seconds - number of seconds from epoch to UTC time (time_t time format)
#
# set UTCBIOS to true if bios is using UTC time
# set UTCBIOS to false if bios is using local time

UTCBIOS=false

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    # clear alarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm   # write the waketime

LOGFILE=/var/log/mythtv/setwakeup.log
cat /proc/driver/rtc > $LOGFILE
cat /sys/class/rtc/rtc0/wakealarm >> $LOGFILE
echo "Argument 1 = $1, SECS = $SECS" >> $LOGFILE

Thanks, Daryl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20130909/97585198/attachment.html>


More information about the mythtv-users mailing list