| 1 | package Protocol::IR::Proto::Dish; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 55 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 55 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 55 | our $VERSION = '1.5'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 55 | ▶ | use Protocol::IR::Code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub new { bless {}, shift } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub decode_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_raw: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my ($class, $raw) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my $val = $raw =~ /^0x/i ? hex($raw) : $raw + 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | protocol => 'Dish_Network', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | bits => 16, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | address => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | subaddress => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | command => $val & 0xffff, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | data => $val & 0xffff, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | sub decode_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_params: called CC=5 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | my $cmd = $args{command} // $args{function} // $args{device} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
(($args{"command"} // $args{"function"}) // $args{"device"}) // 0
($args{"command"} // $args{"function"}) // $args{"device"}
$args{"command"} // $args{"function"}
MC/DC0%0/3
(($args{"command"} // $args{"function"}) // $args{"device"}) // 0
$args{"command"}
$args{"function"}
$args{"device"}
Truth table25%1/4
A // B // C
A= $args{"command"}B= $args{"function"}C= $args{"device"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | $cmd = hex($cmd) if $cmd =~ /^0x/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | $cmd &= 0xffff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | protocol => 'Dish_Network', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | bits => 16, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | address => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | subaddress => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | command => $cmd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | data => $cmd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 137 | ▶ | sub decode_timing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_timing: called CC=13 SCAR=27.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 137 | my ($class, $pairs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 137 | ▶ | return undef unless ref $pairs eq 'ARRAY' && @$pairs >= 17; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $pairs eq "ARRAY" and @$pairs >= 17
MC/DC50%1/2
ref $pairs eq "ARRAY" and @$pairs >= 17
ref $pairs eq "ARRAY"
@$pairs >= 17
Truth table66%2/3
A and B
A= ref $pairs eq "ARRAY"B= @$pairs >= 17
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 64 | my ($hdr_mark, $hdr_space) = @{$pairs->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 64 | ▶ | return undef unless $hdr_mark >= 300 && $hdr_mark <= 500 && $hdr_space >= 5500 && $hdr_space <= 6700; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$hdr_mark >= 300 and $hdr_mark <= 500 and $hdr_space >= 5500 and $hdr_space <= 6700
$hdr_mark >= 300 and $hdr_mark <= 500 and $hdr_space >= 5500
$hdr_mark >= 300 and $hdr_mark <= 500
MC/DC25%1/4
$hdr_mark >= 300 and $hdr_mark <= 500 and $hdr_space >= 5500 and $hdr_space <= 6700
$hdr_mark >= 300
$hdr_mark <= 500
$hdr_space >= 5500
$hdr_space <= 6700
Truth table40%2/5
A and B and C and D
A= $hdr_mark >= 300B= $hdr_mark <= 500C= $hdr_space >= 5500D= $hdr_space <= 6700
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 7 | my $data = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 7 | for my $i (0 .. 15) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 112 | my ($mark, $space) = @{$pairs->[$i + 1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 112 | ▶ | return undef unless $mark >= 300 && $mark <= 500; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$mark >= 300 and $mark <= 500
MC/DC0%0/2
$mark >= 300 and $mark <= 500
$mark >= 300
$mark <= 500
Truth table33%1/3
A and B
A= $mark >= 300B= $mark <= 500
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 112 | my $bit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 112 | my $mid = (1700 + 2800) / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 112 | ▶ | if ($space > $mid) { $bit = 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 17 | ▶ | elsif ($space < $mid && $space >= 850) { $bit = 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$space < $mid and $space >= 850
MC/DC0%0/2
$space < $mid and $space >= 850
$space < $mid
$space >= 850
Truth table33%1/3
A and B
A= $space < $midB= $space >= 850
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | else { return undef; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 112 | $data = ($data << 1) | $bit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 7 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | protocol => 'Dish_Network', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | bits => 16, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | address => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | subaddress => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | command => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | ▶ | sub to_pronto { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_pronto: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | my ($class, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | my $data = $code->{data} & 0xffff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | my $carrier_hz = 57600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my $freq_word = int(1000000.0 / ($carrier_hz * 0.241246) + 0.5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | my $period_us = $freq_word * 0.241246; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | ▶ | my $us_to_pulses = sub { int($_[0] / $period_us + 0.5) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | my @bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | for my $i (reverse 0 .. 15) { push @bits, ($data >> $i) & 1; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | my @pairs = ( [ $us_to_pulses->(400), $us_to_pulses->(6100) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | for my $bit (@bits) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 48 | ▶ | push @pairs, [ $us_to_pulses->(400), $us_to_pulses->($bit ? 1700 : 2800) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | my $seq1 = scalar(@pairs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | my $header = sprintf('0000 %04X %04X 0000', $freq_word, $seq1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | my $payload = join(' ', map { sprintf('%04X %04X', $_->[0], $_->[1]) } @pairs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | return "$header $payload"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 55 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | Protocol::IR::Proto::Dish - IR protocol handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | version 1.5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||