| 1 | package Protocol::IR::Proto::Pioneer; | ||||||||||||||||||||||||||||
| 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 | 55 | ▶ | use Math::BigInt; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 55 | ▶ | use Protocol::IR::Proto::NEC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub new { bless {}, shift } | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | sub _nec_encode { | ||||||||||||||||||||||||||
|
Subroutine
_nec_encode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | my ($addr, $cmd) = @_; | |||||||||||||||||||||||||||
| 15 | # NEC address byte, subaddress default ~addr, command, ~command | ||||||||||||||||||||||||||||
| 16 | 4 | my $sub = (~$addr) & 0xff; | |||||||||||||||||||||||||||
| 17 | 4 | return (($addr & 0xff) << 24) | ($sub << 16) | (($cmd & 0xff) << 8) | ((~$cmd) & 0xff); | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub decode_raw { | ||||||||||||||||||||||||||
|
Subroutine
decode_raw: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 0 | my ($class, $raw) = @_; | |||||||||||||||||||||||||||
| 22 | 0 | my $val; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | if ($raw =~ /^0x/i) { $val = Math::BigInt->from_hex($raw); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 0 | else { $val = Math::BigInt->new($raw); } | |||||||||||||||||||||||||||
| 25 | 0 | my $first = ($val >> 32) & 0xffffffff; | |||||||||||||||||||||||||||
| 26 | 0 | my $second = $val & 0xffffffff; | |||||||||||||||||||||||||||
| 27 | 0 | my $address = ($first >> 8) & 0xff; | |||||||||||||||||||||||||||
| 28 | 0 | my $command = ($second >> 8) & 0xff; | |||||||||||||||||||||||||||
| 29 | 0 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||
| 30 | protocol => 'Pioneer', | ||||||||||||||||||||||||||||
| 31 | bits => 64, | ||||||||||||||||||||||||||||
| 32 | address => $address, | ||||||||||||||||||||||||||||
| 33 | subaddress => -1, | ||||||||||||||||||||||||||||
| 34 | command => $command, | ||||||||||||||||||||||||||||
| 35 | data => $val, | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | sub decode_params { | ||||||||||||||||||||||||||
|
Subroutine
decode_params: called CC=7 SCAR=21.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 2 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 41 | 2 | ▶ | my $address = $args{address} // $args{device} // 0; | ||||||||||||||||||||||||||
|
Condition40%2/5
($args{"address"} // $args{"device"}) // 0
$args{"address"} // $args{"device"}
MC/DC0%0/2
($args{"address"} // $args{"device"}) // 0
$args{"address"}
$args{"device"}
Truth table33%1/3
A // B
A= $args{"address"}B= $args{"device"}
| |||||||||||||||||||||||||||||
| 42 | 2 | ▶ | $address = hex($address) if $address =~ /^0x/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | my $command = $args{command} // $args{function} // 0; | ||||||||||||||||||||||||||
|
Condition40%2/5
($args{"command"} // $args{"function"}) // 0
$args{"command"} // $args{"function"}
MC/DC0%0/2
($args{"command"} // $args{"function"}) // 0
$args{"command"}
$args{"function"}
Truth table33%1/3
A // B
A= $args{"command"}B= $args{"function"}
| |||||||||||||||||||||||||||||
| 44 | 2 | ▶ | $command = hex($command) if $command =~ /^0x/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 2 | $address &= 0xff; | |||||||||||||||||||||||||||
| 46 | 2 | $command &= 0xff; | |||||||||||||||||||||||||||
| 47 | 2 | my $first = _nec_encode(0, $address); | |||||||||||||||||||||||||||
| 48 | 2 | my $second = _nec_encode(0, $command); | |||||||||||||||||||||||||||
| 49 | 2 | my $data = (Math::BigInt->new($first) << 32) | Math::BigInt->new($second); | |||||||||||||||||||||||||||
| 50 | 2 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||
| 51 | protocol => 'Pioneer', | ||||||||||||||||||||||||||||
| 52 | bits => 64, | ||||||||||||||||||||||||||||
| 53 | address => $address, | ||||||||||||||||||||||||||||
| 54 | subaddress => -1, | ||||||||||||||||||||||||||||
| 55 | command => $command, | ||||||||||||||||||||||||||||
| 56 | data => $data, | ||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 939 | ▶ | sub decode_timing { | ||||||||||||||||||||||||||
|
Subroutine
decode_timing: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 939 | my ($class, $pairs) = @_; | |||||||||||||||||||||||||||
| 62 | 939 | ▶ | return undef unless ref $pairs eq 'ARRAY' && @$pairs >= 68; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $pairs eq "ARRAY" and @$pairs >= 68
MC/DC50%1/2
ref $pairs eq "ARRAY" and @$pairs >= 68
ref $pairs eq "ARRAY"
@$pairs >= 68
Truth table66%2/3
A and B
A= ref $pairs eq "ARRAY"B= @$pairs >= 68
| |||||||||||||||||||||||||||||
| 63 | 67 | my $first = Protocol::IR::Proto::NEC->decode_timing([ @{$pairs}[0 .. 33] ]); | |||||||||||||||||||||||||||
| 64 | 67 | ▶ | return undef unless defined $first; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 4 | my $second = Protocol::IR::Proto::NEC->decode_timing([ @{$pairs}[34 .. 67] ]); | |||||||||||||||||||||||||||
| 66 | 4 | ▶ | return undef unless defined $second; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 4 | my $address = ($first->{data} >> 8) & 0xff; | |||||||||||||||||||||||||||
| 68 | 4 | my $command = ($second->{data} >> 8) & 0xff; | |||||||||||||||||||||||||||
| 69 | 4 | my $data = (Math::BigInt->new($first->{data}) << 32) | Math::BigInt->new($second->{data}); | |||||||||||||||||||||||||||
| 70 | 4 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||
| 71 | protocol => 'Pioneer', | ||||||||||||||||||||||||||||
| 72 | bits => 64, | ||||||||||||||||||||||||||||
| 73 | address => $address, | ||||||||||||||||||||||||||||
| 74 | subaddress => -1, | ||||||||||||||||||||||||||||
| 75 | command => $command, | ||||||||||||||||||||||||||||
| 76 | data => $data, | ||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 2 | ▶ | sub to_pronto { | ||||||||||||||||||||||||||
|
Subroutine
to_pronto: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 2 | my ($class, $code) = @_; | |||||||||||||||||||||||||||
| 82 | 2 | my $data = $code->{data}; | |||||||||||||||||||||||||||
| 83 | 2 | my $first = ($data >> 32) & 0xffffffff; | |||||||||||||||||||||||||||
| 84 | 2 | my $second = $data & 0xffffffff; | |||||||||||||||||||||||||||
| 85 | 2 | my $first_code = Protocol::IR::Proto::NEC->decode_raw($first); | |||||||||||||||||||||||||||
| 86 | 2 | my $second_code = Protocol::IR::Proto::NEC->decode_raw($second); | |||||||||||||||||||||||||||
| 87 | 2 | my $p1 = Protocol::IR::Proto::NEC->to_pronto($first_code); | |||||||||||||||||||||||||||
| 88 | 2 | my $p2 = Protocol::IR::Proto::NEC->to_pronto($second_code); | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | my @t1 = split(/\s+/, $p1); | |||||||||||||||||||||||||||
| 91 | 2 | my @t2 = split(/\s+/, $p2); | |||||||||||||||||||||||||||
| 92 | 2 | my $freq_word = $t1[1]; | |||||||||||||||||||||||||||
| 93 | 2 | my $pairs1 = hex($t1[2]); | |||||||||||||||||||||||||||
| 94 | 2 | my $pairs2 = hex($t2[2]); | |||||||||||||||||||||||||||
| 95 | 2 | my $total = $pairs1 + $pairs2; | |||||||||||||||||||||||||||
| 96 | 2 | my $header = sprintf('0000 %s %04X 0000', $freq_word, $total); | |||||||||||||||||||||||||||
| 97 | 2 | my $payload1 = join(' ', @t1[4 .. $#t1]); | |||||||||||||||||||||||||||
| 98 | 2 | my $payload2 = join(' ', @t2[4 .. $#t2]); | |||||||||||||||||||||||||||
| 99 | 2 | return "$header $payload1 $payload2"; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 55 | 1; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 NAME | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Protocol::IR::Proto::Pioneer - IR protocol handler | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 VERSION | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | version 1.5 | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||||||||||