{"id":38,"date":"2008-03-15T21:21:26","date_gmt":"2008-03-15T20:21:26","guid":{"rendered":"http:\/\/www.nooblet.org\/blog\/2008\/mythtv-dvb-reloadpl\/"},"modified":"2013-01-10T03:41:48","modified_gmt":"2013-01-10T03:41:48","slug":"mythtv-dvb-reloadpl","status":"publish","type":"post","link":"https:\/\/www.nooblet.org\/blog\/2008\/mythtv-dvb-reloadpl\/","title":{"rendered":"mythtv-dvb-reload.pl"},"content":{"rendered":"<p>I&#8217;ve been having problems with my Hauppauge WinTV-NOVA-T 500 Dual DVB-T Tuner. Using <a href=\"http:\/\/www.mythtv.org\">MythTV<\/a> every day or so one of the tuners on the card would no longer lock onto any channels. I wasn&#8217;t <a href=\"http:\/\/www.mail-archive.com\/linux-dvb@linuxtv.org\/msg29209.html\">the<\/a> <a href=\"http:\/\/www.gossamer-threads.com\/lists\/mythtv\/users\/306857#306857\">only<\/a> <a href=\"http:\/\/www.gossamer-threads.com\/lists\/mythtv\/users\/307184#307184\">one<\/a>.<\/p>\n<p>As I don&#8217;t have any errors in logs, I can hardly troubleshoot. So I just automate what I have been doing, and that is,<\/p>\n<ul>\n<li>Check the Encoders are idle<\/li>\n<li>Stop Myth Backend<\/li>\n<li>Unload the v4l driver, dvb_usb_dib0700<\/li>\n<li>Reload the v4l driver<\/li>\n<li>Restart Myth Backend<\/li>\n<\/ul>\n<p>The only problem is I can&#8217;t just simply put this in a crontab entry, else I will get interrupted and split recordings.<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>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,<\/p>\n<blockquote><p><code>20080215 19:13.41:debug: Fetching 'http:\/\/localhost:6544\/xml'<br \/>\n20080215 19:13.41:debug: Begin XML parser.<br \/>\n20080215 19:13.41:debug: XML::Parser -&gt; Found element '&lt;Encoders&gt;'<br \/>\n20080215 19:13.41:debug: XML::Parser -&gt; Found element '&lt;Encoder&gt;'<br \/>\n20080215 19:13.41:debug: XML::Parser -&gt; Attribute 'id' = 1<br \/>\n20080215 19:13.41:debug: XML::Parser -&gt; Attribute 'state' = 4<br \/>\n20080215 19:13.41:debug: End XML parser.<br \/>\n20080215 19:13.41:debug: Encoders are busy, waiting 60 seconds.<br \/>\n20080215 19:14.41:debug: Fetching 'http:\/\/localhost:6544\/xml'<br \/>\n20080215 19:14.41:debug: Begin XML parser.<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Found element '&lt;Encoders&gt;'<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Found element '&lt;Encoder&gt;'<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'id' = 1<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'state' = 0<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Found element '&lt;Encoder&gt;'<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'id' = 2<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'state' = 0<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Found element '&lt;Encoder&gt;'<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'id' = 3<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'state' = 0<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Found element '&lt;Encoder&gt;'<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'id' = 4<br \/>\n20080215 19:14.41:debug: XML::Parser -&gt; Attribute 'state' = 0<br \/>\n20080215 19:14.41:debug: End XML parser.<br \/>\n20080215 19:14.41:debug: Encoders are idle, begin restart.<br \/>\n20080215 19:14.41:debug: Executing: '\/etc\/init.d\/mythtv-backend stop'<br \/>\nStopping MythTV server: mythbackend .<br \/>\n20080215 19:14.41:debug: Executing: 'rmmod dvb_usb_dib0700'<br \/>\n20080215 19:14.41:debug: Executing: 'modprobe dvb_usb_dib0700'<br \/>\n20080215 19:14.42:debug: Executing: '\/etc\/init.d\/mythtv-backend start'<br \/>\nStarting MythTV server: mythbackend .<br \/>\n20080215 19:14.42:debug: Backend and Driver reloading complete.<br \/>\n20080215 19:14.42:debug: Sleeping for 3600 seconds. zZz.<br \/>\n<\/code><\/p><\/blockquote>\n<p>You need to run this script as root.<\/p>\n<p>I may modify this should I find out what is triggering the problem. I&#8217;d prefer to only restart Myth when it happens.<br \/>\n<b>Download<\/b><br \/>\n<img decoding=\"async\" src=\"\/blog\/wp-content\/plugins\/wp-downloadmanager\/images\/ext\/unknown.gif\" alt=\"\" title=\"\" style=\"vertical-align: middle;\" \/>&nbsp;&nbsp;<strong><a href=\"https:\/\/www.nooblet.org\/blog\/download\/mythtv-dvb-reload.pl\">mythtv-dvb-reload.pl<\/a><\/strong> (5.1 KiB, 3,118 hits)<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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&#8217;t the only one. As I don&#8217;t have any errors in logs, I can hardly troubleshoot. So I just automate what I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":648,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[43,60,62,233,108,112,124,143],"class_list":["post-38","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-crash","tag-driver","tag-dvb","tag-linux","tag-module","tag-mythtv","tag-perl","tag-script"],"_links":{"self":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":2,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":742,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions\/742"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media\/648"}],"wp:attachment":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}