[mythtv-users] HDPVR Kernel module reload as power cycle
Steven Adeff
adeffs.mythtv at gmail.com
Sat Dec 8 15:55:55 UTC 2012
On Tue, Dec 4, 2012 at 12:26 PM, Michael <mythtv at blandford.net> wrote:
> On 11/30/2012 09:33 AM, Steven Adeff wrote:
>> from the wiki,
>> "If you still experience problems with stability, a small kernel
>> module re-load script is included below in the Bitrate and Picture
>> Controls sub section that re-loads the kernel modules and acts like a
>> power cycle on the HD-PVR." -
>> http://www.mythtv.org/wiki/Hauppauge_HD-PVR#Firmware_Version_Stability
>>
>> Is this correct, that reloading the kernel module for the hdpvr acts
>> as a power cycle negating the need for the user to physically power
>> cycle the device?
>>
>> If so, has anyone figured out a way to initiate a module reload at a
>> time where MythTV won't be using any attached HDPVR devices?
>>
>
> Here is what I use to see if my hdpvrs are in use and if not, power down my
> satellite receiver. You could probably modify it to do what you want.
>
> !/bin/bash
> export PATH=/usr/bin
> MYTHWEBURL=http://<url>/mythweb/status
>
> wget -O - --quiet $MYTHWEBURL | grep HDPVR | \
> while read line; do
> dish=`echo $line | sed -e 's/.*hdpvr\([0-9]\).*/\1/'`
> if `echo $line | grep --quiet 'and is not recording'`; then
> echo "Powering off directv-${dish}"
> /usr/local/bin/directv-${dish} off
> else
> echo "directv-${dish} is busy"
> fi
> done
This system has two hdpvr's so I have to check for the status of both
before power-cycling by reloading the driver.
Here's what I put together,
hdpvr_check.sh
-------------------------
#!/bin/bash
#export PATH=/usr/bin
## mythweb url, should work as long as the script is being run on the
same system as mythweb and apache
MYTHWEBURL=http://localhost/mythweb/status
## if your mythweb is password protected enter your username and password here
MYTHWEBUSER=mythweb
MYTHWEBPASSWORD=c00ldvr
## to limit the time the script will run, place your hour limits here
### in 24h format (ie 1pm=13)
MINHR=2
MAXHR=6
## don't touch these!
STATUS=1
TIME=`date +%H`
TODAY=`date +%F`
## Let's sart!
echo "Hour: " $TIME
if [ "$TIME" -ge "$MINHR" -a "$TIME" -lt "$MAXHR" ]
then
echo "Clear to run at this time!"
wget -O - --quiet --user=$MYTHWEBUSER --password=$MYTHWEBPASSWORD
$MYTHWEBURL | grep HDPVR | \
while read line; do
device=`echo $line | sed -e 's/.*Encoder \([0-9]\).*/\1/'`
if `echo $line | grep --quiet 'and is recording'`; then
echo "however, HDPVR ${device} is busy, we will wait"
STATUS=2
else
echo "HDPVR ${device} is not being used"
fi
done
if [ "$STATUS" -eq "2" ]
then
echo "no devices are in use!"
echo "reloading driver for HDPVR devices..."
#/usr/local/bin/hdpvr_powercycle.sh
export HDPVRRESET=$TODAY
else
echo "an HDPVR is in use, we won't run at this time"
fi
else
echo "Wrong time! We won't run now..."
export HDPVRRESET=0
fi
-------------------------
followed by the script that does the power cycling. right now they are
separate for better testing, but they could be combined,
hdpvr_powercycle.sh
-------------------------
#!/bin/bash
#reloads the hdpvr driver, essentially power cycling the hdpvr devices
modprobe -r -v hdpvr
sleep 5s
modprobe -v hdpvr
-------------------------
then just link to the first one in your CRON folder to run hourly,
which is probably not set to run on the hour exactly, so it shouldn't
disrupt potential recording timing, not that driver reload takes all
that long.
if you want to log the output of the scripts, add
logfile=/var/log/mythtv/hdpvr_powercycle.log
exec >> $logfile 2>&1
to the top of each script.
--
Steve
http://www.mythtv.org/wiki/User:Steveadeff
Before you ask, read the FAQ!
http://www.mythtv.org/wiki/Frequently_Asked_Questions
then search the Wiki, and this list,
http://www.gossamer-threads.com/lists/mythtv/
Mailinglist etiquette - http://www.mythtv.org/wiki/Mailing_List_etiquette
More information about the mythtv-users
mailing list