mythtv-dvb-reload.pl

Posted on .

I’ve been having problems with my Hauppauge WinTV-NOVA-T 500 Dual DVB-T Tuner. Using MythTV every day or so one of the tuners on the card would no longer lock onto any channels. I wasn’t the only one.

As I don’t have any errors in logs, I can hardly troubleshoot. So I just automate what I have been doing, and that is,

  • Check the Encoders are idle
  • Stop Myth Backend
  • Unload the v4l driver, dvb_usb_dib0700
  • Reload the v4l driver
  • Restart Myth Backend

The only problem is I can’t just simply put this in a crontab entry, else I will get interrupted and split recordings.

The script does the above, but only if all the encoders are idle. It checks the xml feed on the backends status port (ie. http://localhost:6544/xml) for the encoder status and will perform the 4 tasks once an hour. If when the next hour comes around and MythTV is busy recording, the script will check each minute until they are idle.

To help you mould it to your system, the url, port, sleep times and the commands that are run can all be modified at the beginning of the scripts.

The script is relatively silent by default, stating it is being run and spurting out errors should they occur. If you want to see what is happening however a -v commandline option shall output something like,

20080215 19:13.41:debug: Fetching 'http://localhost:6544/xml'
20080215 19:13.41:debug: Begin XML parser.
20080215 19:13.41:debug: XML::Parser -> Found element '<Encoders>'
20080215 19:13.41:debug: XML::Parser -> Found element '<Encoder>'
20080215 19:13.41:debug: XML::Parser -> Attribute 'id' = 1
20080215 19:13.41:debug: XML::Parser -> Attribute 'state' = 4
20080215 19:13.41:debug: End XML parser.
20080215 19:13.41:debug: Encoders are busy, waiting 60 seconds.
20080215 19:14.41:debug: Fetching 'http://localhost:6544/xml'
20080215 19:14.41:debug: Begin XML parser.
20080215 19:14.41:debug: XML::Parser -> Found element '<Encoders>'
20080215 19:14.41:debug: XML::Parser -> Found element '<Encoder>'
20080215 19:14.41:debug: XML::Parser -> Attribute 'id' = 1
20080215 19:14.41:debug: XML::Parser -> Attribute 'state' = 0
20080215 19:14.41:debug: XML::Parser -> Found element '<Encoder>'
20080215 19:14.41:debug: XML::Parser -> Attribute 'id' = 2
20080215 19:14.41:debug: XML::Parser -> Attribute 'state' = 0
20080215 19:14.41:debug: XML::Parser -> Found element '<Encoder>'
20080215 19:14.41:debug: XML::Parser -> Attribute 'id' = 3
20080215 19:14.41:debug: XML::Parser -> Attribute 'state' = 0
20080215 19:14.41:debug: XML::Parser -> Found element '<Encoder>'
20080215 19:14.41:debug: XML::Parser -> Attribute 'id' = 4
20080215 19:14.41:debug: XML::Parser -> Attribute 'state' = 0
20080215 19:14.41:debug: End XML parser.
20080215 19:14.41:debug: Encoders are idle, begin restart.
20080215 19:14.41:debug: Executing: '/etc/init.d/mythtv-backend stop'
Stopping MythTV server: mythbackend .
20080215 19:14.41:debug: Executing: 'rmmod dvb_usb_dib0700'
20080215 19:14.41:debug: Executing: 'modprobe dvb_usb_dib0700'
20080215 19:14.42:debug: Executing: '/etc/init.d/mythtv-backend start'
Starting MythTV server: mythbackend .
20080215 19:14.42:debug: Backend and Driver reloading complete.
20080215 19:14.42:debug: Sleeping for 3600 seconds. zZz.

You need to run this script as root.

I may modify this should I find out what is triggering the problem. I’d prefer to only restart Myth when it happens.
Download
  mythtv-dvb-reload.pl (5.1 KiB, 2,686 hits)

Leave a Reply

You may leave the Name and Email fields blank to post anonymously.