File Coverage
| blib/lib/Device/CableModem/Zoom5341J/Parse.pm |
|
| Criterion |
Covered |
Total |
% |
| statement |
70 |
70 |
100.0
|
| branch |
17 |
20 |
85.0
|
| condition |
4 |
6 |
66.6
|
| subroutine |
4 |
4 |
100.0
|
| pod |
0 |
1 |
0.0
|
| total |
95 |
101 |
94.0
|
| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
7
|
|
|
7
|
|
29
|
use strict; |
|
|
7
|
|
|
|
|
6
|
|
|
|
7
|
|
|
|
|
214
|
|
|
2
|
7
|
|
|
7
|
|
25
|
use warnings; |
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
182
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
7
|
|
|
7
|
|
22
|
use Carp; |
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
4685
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Device::CableModem::Zoom5341J::Parse |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NOTA BENE |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This is part of the guts of Device::CableModem::Zoom5341J. If you're |
|
14
|
|
|
|
|
|
|
reading this, you're either developing the module, writing tests, or |
|
15
|
|
|
|
|
|
|
coloring outside the lines; consider yourself warned. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 ->parse_conn_stats |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Parse out all the connection status bits. |
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
sub parse_conn_stats |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
4
|
|
|
4
|
0
|
1449
|
my $self = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
4
|
100
|
|
|
|
22
|
$self->fetch_data unless $self->{conn_html}; |
|
29
|
4
|
100
|
|
|
|
146
|
croak "No HTML stashed" unless $self->{conn_html}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# First extract out a fragment that contains all the downstream and |
|
32
|
|
|
|
|
|
|
# upstream data |
|
33
|
3
|
|
|
|
|
52
|
my ($dsfrag) = ($self->{conn_html} =~ |
|
34
|
|
|
|
|
|
|
m#Downstream Bonded Channels(.+?) |
#s);
|
35
|
3
|
100
|
|
|
|
84
|
croak "Couldn't find downstream fragment" unless $dsfrag; |
|
36
|
2
|
|
|
|
|
19
|
chomp(my @dslines = split /\n/, $dsfrag); |
|
37
|
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
23
|
my ($usfrag) = ($self->{conn_html} =~ |
|
39
|
|
|
|
|
|
|
m#Upstream Bonded Channels(.+?)#s); |
|
40
|
2
|
50
|
|
|
|
5
|
croak "Couldn't find upstream fragment" unless $usfrag; |
|
41
|
2
|
|
|
|
|
10
|
chomp(my @uslines = split /\n/, $usfrag); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Make life easier on regexen |
|
45
|
2
|
|
|
|
|
3
|
my $td = " | ]*>\\s*"; |
|
46
|
2
|
|
|
|
|
3
|
my $etd = "\\s* | ";
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Go through the downstream lines, grabbing the stat bits |
|
49
|
2
|
|
|
|
|
3
|
my %dsstat; |
|
50
|
2
|
|
|
|
|
5
|
for my $l (@dslines) |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
|
|
|
|
|
|
# Grab all the table cells in a line |
|
53
|
22
|
|
|
|
|
284
|
my @tds = ($l =~ m#$td(.*?)$etd#g); |
|
54
|
22
|
100
|
|
|
|
41
|
next unless @tds; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# First should be a channel number |
|
57
|
16
|
50
|
|
|
|
38
|
next unless $tds[0] =~ m#^\d+$#; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Grab the bits we care about |
|
60
|
16
|
|
|
|
|
15
|
my ($chanid) = $tds[0]; |
|
61
|
16
|
|
|
|
|
13
|
my ($mod) = $tds[2]; |
|
62
|
16
|
|
|
|
|
34
|
my ($freq) = ($tds[4] =~ m#(\d+) Hz#); |
|
63
|
16
|
|
|
|
|
34
|
my ($power) = ($tds[5] =~ m#([\d.]+) dBmV#); |
|
64
|
16
|
|
|
|
|
31
|
my ($snr) = ($tds[6] =~ m#([\d.]+) dB#); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# And stash them |
|
67
|
16
|
|
|
|
|
16
|
push @{$dsstat{chanid}}, $chanid; |
|
|
16
|
|
|
|
|
26
|
|
|
68
|
16
|
|
|
|
|
9
|
push @{$dsstat{mod}}, $mod; |
|
|
16
|
|
|
|
|
18
|
|
|
69
|
16
|
|
|
|
|
14
|
push @{$dsstat{freq}}, $freq; |
|
|
16
|
|
|
|
|
19
|
|
|
70
|
16
|
|
|
|
|
8
|
push @{$dsstat{power}}, $power; |
|
|
16
|
|
|
|
|
30
|
|
|
71
|
16
|
|
|
|
|
14
|
push @{$dsstat{snr}}, $snr; |
|
|
16
|
|
|
|
|
47
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
7
|
$self->{conn_stats}{down} = \%dsstat; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Now do the same for upstream |
|
78
|
2
|
|
|
|
|
2
|
my %usstat; |
|
79
|
2
|
|
|
|
|
4
|
for my $l (@uslines) |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
|
|
|
|
|
|
# Grab all the table cells in a line |
|
82
|
12
|
|
|
|
|
122
|
my @tus = ($l =~ m#$td(.*?)$etd#g); |
|
83
|
12
|
100
|
|
|
|
22
|
next unless @tus; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# First should be a channel number |
|
86
|
8
|
50
|
|
|
|
22
|
next unless $tus[0] =~ m#^\d+$#; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Grab the bits we care about |
|
89
|
8
|
|
|
|
|
10
|
my ($chanid) = $tus[0]; |
|
90
|
8
|
|
|
|
|
22
|
my ($bw) = ($tus[4] =~ m#(\d+) Ksym/sec#); |
|
91
|
8
|
|
|
|
|
15
|
my ($freq) = ($tus[5] =~ m#(\d+) Hz#); |
|
92
|
8
|
|
|
|
|
17
|
my ($power) = ($tus[6] =~ m#([\d.]+) dBmV#); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# And stash them |
|
95
|
8
|
|
|
|
|
7
|
push @{$usstat{chanid}}, $chanid; |
|
|
8
|
|
|
|
|
15
|
|
|
96
|
8
|
|
|
|
|
5
|
push @{$usstat{bw}}, $bw; |
|
|
8
|
|
|
|
|
9
|
|
|
97
|
8
|
|
|
|
|
6
|
push @{$usstat{freq}}, $freq; |
|
|
8
|
|
|
|
|
8
|
|
|
98
|
8
|
|
|
|
|
9
|
push @{$usstat{power}}, $power; |
|
|
8
|
|
|
|
|
17
|
|
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
5
|
$self->{conn_stats}{up} = \%usstat; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Now empty out up/down channels as necessary |
|
105
|
2
|
|
|
|
|
3
|
my $ds = $self->{conn_stats}{down}; |
|
106
|
2
|
|
|
|
|
5
|
for my $i (0..$#{$ds->{freq}}) |
|
|
2
|
|
|
|
|
6
|
|
|
107
|
|
|
|
|
|
|
{ |
|
108
|
16
|
100
|
66
|
|
|
60
|
unless($ds->{freq}[$i] && $ds->{freq}[$i] > 0) |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
2
|
|
|
|
|
14
|
undef($ds->{$_}[$i]) for keys %$ds; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
5
|
my $us = $self->{conn_stats}{up}; |
|
115
|
2
|
|
|
|
|
2
|
for my $i (0..$#{$us->{chanid}}) |
|
|
2
|
|
|
|
|
5
|
|
|
116
|
|
|
|
|
|
|
{ |
|
117
|
8
|
100
|
66
|
|
|
23
|
unless($us->{freq}[$i] && $us->{freq}[$i] > 0) |
|
118
|
|
|
|
|
|
|
{ |
|
119
|
4
|
|
|
|
|
13
|
undef($us->{$_}[$i]) for keys %$us; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
2
|
|
|
|
|
9
|
return; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |
|
128
|
|
|
|
|
|
|
__END__ |