| 1 | package Protocol::IR::Proto::GICable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 => 'G.I.Cable', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | bits => 16, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | address => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | subaddress => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | command => $val & 0xffff, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | data => $val & 0xffff, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | sub decode_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_params: called CC=5 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | 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 | 2 | ▶ | $cmd = hex($cmd) if $cmd =~ /^0x/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | $cmd &= 0xffff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | protocol => 'G.I.Cable', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | bits => 16, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | address => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | subaddress => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | command => $cmd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | data => $cmd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 141 | ▶ | sub decode_timing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_timing: called CC=13 SCAR=26.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 141 | my ($class, $pairs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 141 | ▶ | 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 | 68 | my ($hm, $hs) = @{$pairs->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 68 | ▶ | return undef unless $hm >= 8000 && $hm <= 10000 && $hs >= 3800 && $hs <= 5000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$hm >= 8000 and $hm <= 10000 and $hs >= 3800 and $hs <= 5000
$hm >= 8000 and $hm <= 10000 and $hs >= 3800
$hm >= 8000 and $hm <= 10000
MC/DC25%1/4
$hm >= 8000 and $hm <= 10000 and $hs >= 3800 and $hs <= 5000
$hm >= 8000
$hm <= 10000
$hs >= 3800
$hs <= 5000
Truth table40%2/5
A and B and C and D
A= $hm >= 8000B= $hm <= 10000C= $hs >= 3800D= $hs <= 5000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | my $data = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | for my $i (0 .. 15) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 66 | my ($mark, $space) = @{$pairs->[$i + 1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 66 | ▶ | return undef unless $mark >= 400 && $mark <= 700; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$mark >= 400 and $mark <= 700
MC/DC0%0/2
$mark >= 400 and $mark <= 700
$mark >= 400
$mark <= 700
Truth table33%1/3
A and B
A= $mark >= 400B= $mark <= 700
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 66 | my $bit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 66 | my $mid = (4400 + 2200) / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 66 | ▶ | if ($space > $mid) { $bit = 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 56 | ▶ | elsif ($space < $mid && $space >= 1100) { $bit = 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$space < $mid and $space >= 1100
MC/DC50%1/2
$space < $mid and $space >= 1100
$space < $mid
$space >= 1100
Truth table66%2/3
A and B
A= $space < $midB= $space >= 1100
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | else { return undef; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 64 | $data = ($data << 1) | $bit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | return Protocol::IR::Code->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | protocol => 'G.I.Cable', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | bits => 16, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | address => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | subaddress => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | command => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | sub to_pronto { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_pronto: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | my ($class, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | my $data = $code->{data} & 0xffff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | my $carrier_hz = 38000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | my $freq_word = int(1000000.0 / ($carrier_hz * 0.241246) + 0.5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | my $period_us = $freq_word * 0.241246; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ▶ | my $us_to_pulses = sub { int($_[0] / $period_us + 0.5) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | my @bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | for my $i (reverse 0 .. 15) { push @bits, ($data >> $i) & 1; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | my @pairs = ( [ $us_to_pulses->(9000), $us_to_pulses->(4400) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | for my $bit (@bits) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 32 | ▶ | push @pairs, [ $us_to_pulses->(550), $us_to_pulses->($bit ? 4400 : 2200) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | my $seq1 = scalar(@pairs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | my $header = sprintf('0000 %04X %04X 0000', $freq_word, $seq1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my $payload = join(' ', map { sprintf('%04X %04X', $_->[0], $_->[1]) } @pairs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | return "$header $payload"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 55 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | Protocol::IR::Proto::GICable - IR protocol handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | version 1.5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||