Ticket #7348: unified_firewire_primer.patch

File unified_firewire_primer.patch, 2.5 KB (added by anonymous, 11 years ago)
  • firewire_primer.

    old new  
    1616# @license   GPL
    1717# @copyright MythTV
    1818#
     19# Modified: 2009-10-16
     20# Modification Author: John Baab (rhpot1991@ubuntu.com)
     21# Modification Description: Added command line args so this will be easier to support in Mythbuntu
     22#
    1923
    2024###############################################################################
    2125
     
    2327
    2428    my $plugreport      = '/usr/bin/plugreport';
    2529    my $firewire_tester = '/usr/local/bin/firewire_tester';
     30    my $retry = 0;
     31    my $connection = "";
     32    my $fw_tester_options = "-B";
     33   
     34    my $usage = "\nHow to use firewire_primer.pl:\n"
     35    ."--connection -c = Type of connection, available options: broadcast, p2p, broadcast-fix.  (default: broadcast-fix)\n"
     36    ."--retry -r = Retry attempts, any integer.  (default: 1)\n"
     37    ."--help -h = Displays Help.\n"
     38    ."\nExamples:\nfirewire_primer.pl --connection=broadcast --retry=5"
     39    ."\nfirewire_primer.pl -c=broadcast -r=5"
     40    ."\nfirewire_primer.pl -cbroadcast -r5\n\n";
    2641
    2742###############################################################################
    2843
    2944# Some helpful libraries
    3045    use MythTV;
    3146    use Sys::Hostname;
     47   
     48# Get our command line args
     49    foreach (@ARGV){
     50        if ($_ =~ m/\-\-retry=(\d+)/ || $_ =~ m/\-r=?(\d+)/) {
     51            $retry = $1;
     52        }
     53        elsif ($_ =~ m/\-\-connection=(\w+)/ || $_ =~ m/\-c=?(\w+)/) {
     54            $connection = $1;
     55        }
     56        else{
     57            die "$usage";
     58        }
     59    }
     60   
     61# Figure out what to do with the args   
     62    if($connection =~ m/^broadcast$/){
     63        $fw_tester_options = "-b";
     64    }
     65    elsif($connection =~ m/^p2p$/){
     66        $fw_tester_options = "-p";
     67    }
     68    else{
     69        if($connection !~ m/^broadcast\-fix$/  && $connection ne ""){
     70            die "$usage";
     71        }
     72    }
     73   
     74    if($retry > 0){
     75        $fw_tester_options .= " -r $retry";
     76    }
    3277
    3378# Plugreport, etc needs to run as root.
    3479    BEGIN {
     
    76121        my $overload;
    77122        for (;;) {
    78123            $overload++;
    79             my $results = `$firewire_tester -B -P $guid_list{$guid}{host} -n $guid_list{$guid}{node}`;
     124            my $results = `$firewire_tester $fw_tester_options -P $guid_list{$guid}{host} -n $guid_list{$guid}{node}`;
    80125            my $num =()= $results =~ /Success,\s+\d+\s+packets/g;
    81126            if ($num >= 5) {
    82127                print "    success.\n";