blib/lib/Net/UCP.pm

filter: Statementstmt 15.1% 111 / 735 Branchbran 9.2% 58 / 624 Conditioncond 2.5% 5 / 195 MC/DCmcdc 0.0% 0 / 130 Subroutinesub 33.3% 21 / 63 Podpod 26.6% 12 / 45 totaltotal 11.5% 207 / 1792 CC 381 SCAR 60.3
CC
381
Cov
11%
create_fake_smsc
1122.0
make_03
870.0
make_61
650.0
CRAP 416.9
↑ Summary
1 #########################################################################
2 # - Net::UCP 0.41 -
3 #
4 # Version : 0.41
5 # Date : 06/04/2010
6 #
7 # Library based on EMI - UCP INTERFACE Specification
8 # Version 3.5 of December 1999
9 # Spcification Copyright (C) CMG telecommunication & Utilities BV Division
10 # Advanced Technology
11 #
12 # Library Copyright (C) 2004-2009 Marco Romano <nemux@cpan.org>
13 #
14 # This library is free software; you can redistribute it and/or modify
15 # it under the same terms as Perl itself, either Perl version 5.8.4 or,
16 # at your option, any later version of Perl 5 you may have available.
17 #
18 #########################################################################
19 package Net::UCP;
20  
21 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use IO::Select;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Time::HiRes qw(setitimer ITIMER_REAL);
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶use Net::UCP::Common qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use Net::UCP::IntTimeout;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use Net::UCP::TransactionManager;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 1 require Exporter;
33  
34 1 ▶use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 1 @ISA = qw(Exporter);
37 1 @EXPORT = qw();
38 1 @EXPORT_OK = ();
39  
40 1 $VERSION = '0.41';
41  
42 1 $VERSION = eval $VERSION;
43  
44 1 ▶use constant TRUE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 1 ▶BEGIN { *logout = *close_link; }
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 1 ▶sub new { bless({}, shift())->_init(@_); }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
49  
50 # login to SMSC
51 0 ▶sub login {
Subroutine login: not called CC=18 SCAR=58.3
Pod documented
52 0 my $self = shift();
53
54 0 my %args = (
55 SMSC_ID => '',
56 SMSC_PW => '',
57 SHORT_CODE => undef,
58 ONPI => '',
59 OTON => '',
60 STYP => 1, #def 1 (open session)
61 VERS => '0100', #def 0100
62 @_);
63  
64 # Conditionally open the socket unless already opened.
65 0 ▶ $self->open_link() unless(defined($self->{SOCK}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"SOCK"} 0 0 0
66 0 ▶ unless(defined($self->{SOCK})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"SOCK"}) 0 0 0
67 0 ▶ return(defined(wantarray)?wantarray?(undef,0,''):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
68 }
69  
70 0 ▶ defined($args{SMSC_ID})&&length($args{SMSC_ID})||do {
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"SMSC_ID"} and length $args{"SMSC_ID"} or do { $self->{"WARN"} and warn "Missing mandatory parameter 'SMSC_ID' when trying to login. Login failed"; return defined wantarray ? wantarray ? (undef, 0, "") : undef : undef } 0 0 0
Condition0%0/3
defined $args{"SMSC_ID"} and length $args{"SMSC_ID"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"SMSC_ID"} and length $args{"SMSC_ID"}
defined $args{"SMSC_ID"} length $args{"SMSC_ID"}
Truth table0%0/3
A and B
A= defined $args{"SMSC_ID"}B= length $args{"SMSC_ID"}
ABresult
0X0
100
111
71 0 ▶ $self->{WARN}&&warn("Missing mandatory parameter 'SMSC_ID' when trying to login. Login failed");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn "Missing mandatory parameter 'SMSC_ID' when trying to login. Login failed" 0 0 0
72 0 ▶ return(defined(wantarray)?wantarray?(undef,0,''):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
73 };
74
75 0 ▶ defined($args{SMSC_PW})&&length($args{SMSC_PW})||do {
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"SMSC_PW"} and length $args{"SMSC_PW"} or do { $self->{"WARN"} and warn "Missing mandatory parameter 'SMSC_PW' when trying to login. Login failed"; return defined wantarray ? wantarray ? (undef, 0, "") : undef : undef } 0 0 0
Condition0%0/3
defined $args{"SMSC_PW"} and length $args{"SMSC_PW"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"SMSC_PW"} and length $args{"SMSC_PW"}
defined $args{"SMSC_PW"} length $args{"SMSC_PW"}
Truth table0%0/3
A and B
A= defined $args{"SMSC_PW"}B= length $args{"SMSC_PW"}
ABresult
0X0
100
111
76 0 ▶ $self->{WARN}&&warn("Missing mandatory parameter 'SMSC_PW' when trying to login. Login failed");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn "Missing mandatory parameter 'SMSC_PW' when trying to login. Login failed" 0 0 0
77 0 ▶ return(defined(wantarray)?wantarray?(undef,0,''):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
78 };
79  
80 my $message_string = $self->make_message(
81 op => '60',
82 operation => 1,
83 oadc => $args{SMSC_ID},
84 oton => $args{OTON},
85 onpi => $args{ONPI},
86 styp => $args{STYP},
87 pwd => $args{SMSC_PW},
88 vers => $args{VERS}
89 0 );
90
91 0 ▶ if ( defined $message_string ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $message_string) { } 0 0 0
92 0 my $timeout = $self->{TIMEOUT_OBJ}->get();
93 0 $self->transmit_msg($message_string, $timeout, 1);
94 } else {
95 0 ▶ return(defined(wantarray)?wantarray?(undef,0,''):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
96 }
97 }
98  
99 # This method will also conditionally be called from the login() method.
100 0 ▶sub open_link {
Subroutine open_link: not called CC=5 SCAR=34.0
Pod documented
101 0 my $self = shift;
102
103 $self->{SOCK} = IO::Socket::INET->new(
104 PeerAddr => $self->{SMSC_HOST},
105 PeerPort => $self->{SMSC_PORT},
106 Proto => 'tcp',
107 LocalAddr => defined($self->{SRC_HOST}) ? $self->{SRC_HOST} : undef,
108 LocalPort => defined($self->{SRC_PORT}) ? $self->{SRC_PORT} : undef
109 0 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{'SRC_HOST'} ? : 0 0 0
defined $self->{'SRC_PORT'} ? : 0 0 0
110  
111 0 ▶ defined($self->{SOCK})||do {
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"SOCK"} or do { $self->{"WARN"} and warn qq[Failed to establish a socket connection with host $self->{"SMSC_HOST"} on port $self->{"SMSC_PORT"} : $!]; return } 0 0 0
112 0 ▶ $self->{WARN}&&warn("Failed to establish a socket connection with host $self->{SMSC_HOST} on port $self->{SMSC_PORT} : $!");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn qq[Failed to establish a socket connection with host $self->{"SMSC_HOST"} on port $self->{"SMSC_PORT"} : $!] 0 0 0
113 0 return;
114 };
115 0 TRUE;
116 }
117  
118  
119 # To avoid keeping the socket open if not used any more.
120 0 ▶sub close_link {
Subroutine close_link: not called CC=2 SCAR=17.9
Pod documented
121 0 my $self = shift;
122  
123 0 ▶ defined($self->{SOCK})||return;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"SOCK"} or return 0 0 0
124
125 0 close($self->{SOCK});
126 0 $self->{SOCK}=undef;
127 0 $self->{TRN_OBJ}->reset_trn();
128 0 TRUE;
129 }
130  
131 # send SMS
132 0 ▶sub send_sms {
Subroutine send_sms: not called CC=23 SCAR=63.1
Pod documented
133 0 my $self = shift();
134 0 my %args = (
135 RECIPIENT => '',
136 MESSAGE_TEXT => '',
137 SENDER_TEXT => '',
138 UDH => '',
139 MESSAGE_BINARY => undef,
140 FLASH => undef,
141 TIMEOUT => undef,
142 @_);
143  
144 0 my $timeout;
145  
146 0 ▶ if(defined($args{TIMEOUT})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{'TIMEOUT'}) { } 0 0 0
147 0 my $tv = Net::UCP::IntTimeout->new( TIMEOUT => $args{TIMEOUT} );
148 0 $timeout = $tv->get();
149 }
150 else {
151 0 $timeout = $self->{TIMEOUT_OBJ}->get();
152 }
153  
154 0 ▶ defined($args{RECIPIENT})&&length($args{RECIPIENT})||do {
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"RECIPIENT"} and length $args{"RECIPIENT"} or do { $self->{"WARN"} and warn "Missing mandatory parameter 'RECIPIENT' when trying to send message. Transmission failed"; return defined wantarray ? wantarray ? (undef, 0, "") : undef : undef } 0 0 0
Condition0%0/3
defined $args{"RECIPIENT"} and length $args{"RECIPIENT"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"RECIPIENT"} and length $args{"RECIPIENT"}
defined $args{"RECIPIENT"} length $args{"RECIPIENT"}
Truth table0%0/3
A and B
A= defined $args{"RECIPIENT"}B= length $args{"RECIPIENT"}
ABresult
0X0
100
111
155 0 ▶ $self->{WARN}&&warn("Missing mandatory parameter 'RECIPIENT' when trying to send message. Transmission failed");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn "Missing mandatory parameter 'RECIPIENT' when trying to send message. Transmission failed" 0 0 0
156 0 ▶ return(defined(wantarray)?wantarray?(undef,0,''):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
157 };
158  
159 0 $args{RECIPIENT}=~s/^\+/00/;
160 0 ▶ $args{RECIPIENT}=~/^\d+$/||do{
Branch: 1 branch
BranchTrueFalseTotal
$args{"RECIPIENT"} =~ /^\d+$/ or do { $self->{"WARN"} and warn qq[The recipient address contains illegal (non-numerical) characters: $args{"RECIPIENT"}\nMessage not sent ]; return defined wantarray ? wantarray ? (undef, 0, "") : undef : undef } 0 0 0
161 0 ▶ $self->{WARN}&&warn("The recipient address contains illegal (non-numerical) characters: $args{RECIPIENT}\nMessage not sent ");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn qq[The recipient address contains illegal (non-numerical) characters: $args{"RECIPIENT"}\nMessage not sent ] 0 0 0
162 0 ▶ return(defined(wantarray)?wantarray?(undef,0,''):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
163 };
164  
165 # It's OK to send an empty message, but not to use undef.
166 0 ▶ defined($args{MESSAGE_TEXT})||($args{MESSAGE_TEXT}=' ');
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"MESSAGE_TEXT"} or $args{"MESSAGE_TEXT"} = " " 0 0 0
167  
168 0 my $oadcTmp = '';
169 0 my $otoaTmp = '';
170  
171 ($oadcTmp, $otoaTmp) = $self->_get_info_from($args{SENDER_TEXT}) if ((defined($args{SENDER_TEXT})
172 and
173 0 ▶ length($args{SENDER_TEXT})));
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"SENDER_TEXT"} and length $args{"SENDER_TEXT"} 0 0 0
Condition0%0/3
defined $args{"SENDER_TEXT"} and length $args{"SENDER_TEXT"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"SENDER_TEXT"} and length $args{"SENDER_TEXT"}
defined $args{"SENDER_TEXT"} length $args{"SENDER_TEXT"}
Truth table0%0/3
A and B
A= defined $args{"SENDER_TEXT"}B= length $args{"SENDER_TEXT"}
ABresult
0X0
100
111
174
175 0 ▶ my $mclsTmp = (defined($args{FLASH}) and ($args{FLASH} == 1)) ? 1 : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'FLASH'} && $args{'FLASH'} == 1 ? : 0 0 0
Condition0%0/3
defined $args{"FLASH"} and $args{"FLASH"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"FLASH"} and $args{"FLASH"} == 1
defined $args{"FLASH"} $args{"FLASH"} == 1
Truth table0%0/3
A and B
A= defined $args{"FLASH"}B= $args{"FLASH"} == 1
ABresult
0X0
100
111
176 0 ▶ my $class = ($mclsTmp) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$mclsTmp ? : 0 0 0
177
178 my %param_tmp = (
179 op => '51',
180 operation => 1,
181 adc => $args{RECIPIENT},
182 oadc => $oadcTmp,
183 ac => $self->{SHORT_CODE},
184 mt => (defined($args{MESSAGE_BINARY}) ? '4' : '3'),
185 nb => (defined($args{MESSAGE_BINARY}) ?
186 (length($args{MESSAGE_BINARY})/2)*8 : ''),
187 dcs => (defined($args{MESSAGE_BINARY}) ? '1' : ''),
188 mcls => $mclsTmp,
189 otoa => $otoaTmp,
190 xser => (defined($args{MESSAGE_BINARY})
191 &&
192 defined($args{MESSAGE_BINARY})
193 ?
194 0 ▶ make_xser("B", $args{UDH}, $class) : make_xser("T", $args{UDH}, $class)
Branch: 4 branches
BranchTrueFalseTotal
defined $args{'MESSAGE_BINARY'} ? : 0 0 0
defined $args{'MESSAGE_BINARY'} ? : 0 0 0
defined $args{'MESSAGE_BINARY'} ? : 0 0 0
defined $args{'MESSAGE_BINARY'} && defined $args{'MESSAGE_BINARY'} ? : 0 0 0
Condition0%0/3
defined $args{"MESSAGE_BINARY"} and defined $args{"MESSAGE_BINARY"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"MESSAGE_BINARY"} and defined $args{"MESSAGE_BINARY"}
defined $args{"MESSAGE_BINARY"} defined $args{"MESSAGE_BINARY"}
Truth table0%0/3
A and B
A= defined $args{"MESSAGE_BINARY"}B= defined $args{"MESSAGE_BINARY"}
ABresult
0X0
100
111
195 )
196 );
197
198 0 ▶ if (defined $args{MESSAGE_BINARY}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{'MESSAGE_BINARY'}) { } 0 0 0
199 0 $param_tmp{tmsg} = $args{MESSAGE_BINARY};
200 } else {
201 0 $param_tmp{amsg} = $args{MESSAGE_TEXT};
202 }
203  
204 0 my $message_string = $self->make_message(%param_tmp);
205  
206 0 $self->transmit_msg($message_string, $timeout, 1);
207 }
208  
209  
210 0 ▶sub send_sms_multipart {
Subroutine send_sms_multipart: not called CC=5 SCAR=34.0
Pod documented
211 0 my $self = shift;
212 0 my %argsLong =(RECIPIENT => '',
213 MESSAGE_TEXT => '',
214 SENDER_TEXT => '',
215 UDH => undef,
216 MESSAGE_BINARY => undef,
217 FLASH => undef,
218 TIMEOUT => undef,
219 @_);
220  
221 0 my $messageId = random_int(1,255);
222 0 my $multiHash;
223 0 my $countPart = 0;
224
225 0 foreach my $chunk ($argsLong{MESSAGE_TEXT}=~m/(.{1,134})/sg){
226 0 $multiHash->{++$countPart} = $chunk;
227 }
228 0 ▶ while (my ($k, $textChunk) = each %{$multiHash}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$multiHash;}) 0 0 0
229 0 my $udh=sprintf('%s%02X%02X%02X',"0106050003",$messageId,$countPart,$k);
230 my $ret = $self->send_sms(
231 RECIPIENT => $argsLong{RECIPIENT},
232 MESSAGE_TEXT => $textChunk,
233 SENDER_TEXT => $argsLong{SENDER_TEXT},
234 0 UDH => $udh
235 );
236
237 0 ▶ return $ret if (!$ret || !defined($ret)); #it could be better
Branch: 1 branch
BranchTrueFalseTotal
unless $ret and defined $ret 0 0 0
Condition0%0/3
$ret and defined $ret
!ll&&!rl&&r
000
MC/DC0%0/2
$ret and defined $ret
$ret defined $ret
Truth table0%0/3
A and B
A= $retB= defined $ret
ABresult
0X0
100
111
238  
239 }
240
241 0 return TRUE;
242  
243 }
244  
245 0 ▶sub random_int ($$) {
Subroutine random_int: not called CC=3 SCAR=24.8
Pod undocumented
246 0 my($min, $max) = @_;
247  
248 0 ▶ return $min if $min == $max;
Branch: 1 branch
BranchTrueFalseTotal
if $min == $max 0 0 0
249
250 0 ▶ ($min, $max) = ($max, $min) if $min > $max;
Branch: 1 branch
BranchTrueFalseTotal
if $min > $max 0 0 0
251 0 return $min + int rand(1 + $max - $min);
252  
253 }
254  
255  
256 0 ▶sub _get_info_from {
Subroutine _get_info_from: not called CC=6 SCAR=37.4
257 0 my ($self, $from) = @_;
258
259 0 my ($oadc_tmp, $otoa_tmp);
260  
261 0 ▶ if ($from =~ /^([0-9]+)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($from =~ /^([0-9]+)$/) { } 0 0 0
elsif ($from =~ /^\+([0-9]+)$/) { } 0 0 0
262 0 $otoa_tmp = '';
263 0 ▶ if (length ($from) > 22) {substr($from,22) = ''}
Branch: 1 branch
BranchTrueFalseTotal
if (length $from > 22) 0 0 0
264 0 $oadc_tmp = $from;
265 } elsif ($from =~ /^\+([0-9]+)$/) {
266 0 $from =~ s/^.//;
267 0 $otoa_tmp = '1139';
268 0 ▶ if (length ($from) > 22) {substr($from,22) = ''}
Branch: 1 branch
BranchTrueFalseTotal
if (length $from > 22) 0 0 0
269 0 $oadc_tmp = $from;
270 } else {
271 0 $otoa_tmp = '5039';
272 0 ▶ if (length ($from) > 11) {substr($from,11) = ''}
Branch: 1 branch
BranchTrueFalseTotal
if (length $from > 11) 0 0 0
273 0 $oadc_tmp = $from;
274 }
275
276 0 return ($oadc_tmp,$otoa_tmp);
277 }
278  
279  
280 #make_xser() subfunction.
281 #
282 #Parameters:
283 #1)Message Type (it can be "T" -> Text or "B" -> Binary messages)
284 #2)UserDataHeader (in hexadecimal without octet length)
285 #3)Message Class (optional)
286 ##################################
287 0 ▶sub make_xser {
Subroutine make_xser: not called CC=9 SCAR=45.0
Pod undocumented
288 0 my $type=shift;
289 0 my $udh=shift;
290 0 my $class=shift;
291  
292 0 my $xser_ret = '';
293
294 0 ▶ $class = 1 if ($class eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "" 0 0 0
295  
296 #count UDH octest numbers
297 0 my $udh_len = sprintf("%02X",length($udh)/2);
298  
299 #count octets numbers of DD field
300 #numero totale di ottetti
301 0 my $udh_oct = sprintf("%02X",(length($udh)/2)+1);
302  
303 0 ▶ if (not $class) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $class) { } 0 0 0
304  
305 0 ▶ $type eq "T" and $xser_ret='020110';
Branch: 1 branch
BranchTrueFalseTotal
$type eq "T" and $xser_ret = "020110" 0 0 0
306
307 0 ▶ if ($udh =~ m/\d+/ and $type eq "T") {
Branch: 1 branch
BranchTrueFalseTotal
if ($udh =~ /\d+/ and $type eq "T") 0 0 0
Condition0%0/3
$udh =~ /\d+/ and $type eq "T"
!ll&&!rl&&r
000
MC/DC0%0/2
$udh =~ /\d+/ and $type eq "T"
$udh =~ /\d+/ $type eq "T"
Truth table0%0/3
A and B
A= $udh =~ /\d+/B= $type eq "T"
ABresult
0X0
100
111
308 0 $xser_ret = $udh;
309 }
310
311 } else {
312
313 0 ▶ if ($udh =~ m/\d+/ and $type eq "T") {
Branch: 1 branch
BranchTrueFalseTotal
if ($udh =~ /\d+/ and $type eq 'T') { } 0 0 0
Condition0%0/3
$udh =~ /\d+/ and $type eq "T"
!ll&&!rl&&r
000
MC/DC0%0/2
$udh =~ /\d+/ and $type eq "T"
$udh =~ /\d+/ $type eq "T"
Truth table0%0/3
A and B
A= $udh =~ /\d+/B= $type eq "T"
ABresult
0X0
100
111
314 0 $xser_ret = $udh;
315 } else {
316 0 $xser_ret='';
317 }
318
319 }
320
321 #XSER for binary message with udh
322 #XSER multipart
323 #TT 02 -> Xser per DCS
324 #LL 01 -> ottetti DD
325 #DD 00 -> imposta data coding scheme a 8 bit
326 #TT 01 -> Xser per UDH
327 #LL $udh_oct -> otetti UDH information field
328 #DD -> contiene UDH field specificato dall'utente
329
330 0 ▶ $type eq "B" and $xser_ret='02011501'.$udh_oct.$udh_len.$udh;
Branch: 1 branch
BranchTrueFalseTotal
$type eq "B" and $xser_ret = '02011501' . $udh_oct . $udh_len . $udh 0 0 0
331
332 0 return $xser_ret;
333
334 }
335  
336 1 ▶sub _init {
Subroutine _init: called CC=18 SCAR=55.7
337 1 my $self = shift;
338  
339 1 $self->{OBJ_EMI_COMMON} = new Net::UCP::Common;
340 1 $self->{TRN_OBJ} = new Net::UCP::TransactionManager;
341 1 $self->{TIMEOUT_OBJ} = new Net::UCP::IntTimeout;
342
343 1 ▶ return $self if @_ == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 0 1 0 1
344
345 0 my %args = (
346 FAKE => 0,
347 SMSC_HOST => '',
348 SMSC_PORT => DEF_SMSC_PORT,
349 SENDER_TEXT => '',
350 WARN => 0,
351 TIMEOUT => undef,
352 SRC_HOST => undef,
353 SRC_PORT => undef,
354 @_);
355  
356 0 ▶ if ($args{FAKE} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"FAKE"} == 0) 0 0 0
357  
358 0 ▶ $self->{WARN} = defined($args{WARN}) ? $args{WARN} ? 1 : 0 : 0;
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'WARN'} ? : 0 0 0
$args{'WARN'} ? : 0 0 0
359 0 $self->{TIMEOUT_OBJ}->set($args{TIMEOUT});
360
361 0 ▶ defined($args{SMSC_HOST}) && length($args{SMSC_HOST}) || do {
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"SMSC_HOST"} and length $args{"SMSC_HOST"} or do { $self->{"WARN"} and warn "Mandatory entity 'SMSC_HOST' was missing when creating an object of class Net::UCP. Object not created"; return } 0 0 0
Condition0%0/3
defined $args{"SMSC_HOST"} and length $args{"SMSC_HOST"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"SMSC_HOST"} and length $args{"SMSC_HOST"}
defined $args{"SMSC_HOST"} length $args{"SMSC_HOST"}
Truth table0%0/3
A and B
A= defined $args{"SMSC_HOST"}B= length $args{"SMSC_HOST"}
ABresult
0X0
100
111
362 0 ▶ $self->{WARN}&&warn("Mandatory entity 'SMSC_HOST' was missing when creating an object of class ".
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn "Mandatory entity 'SMSC_HOST' was missing when creating an object of class Net::UCP. Object not created" 0 0 0
363 __PACKAGE__.
364 ". Object not created");
365 0 return; # Failed to instantiate this object.
366 };
367 0 ▶ defined($args{SMSC_PORT})&&length($args{SMSC_PORT})||do{
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"SMSC_PORT"} and length $args{"SMSC_PORT"} or do { $self->{"WARN"} and warn "Mandatory entity 'SMSC_PORT' was missing when creating an object of class Net::UCP. Object not created"; return } 0 0 0
Condition0%0/3
defined $args{"SMSC_PORT"} and length $args{"SMSC_PORT"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"SMSC_PORT"} and length $args{"SMSC_PORT"}
defined $args{"SMSC_PORT"} length $args{"SMSC_PORT"}
Truth table0%0/3
A and B
A= defined $args{"SMSC_PORT"}B= length $args{"SMSC_PORT"}
ABresult
0X0
100
111
368 0 ▶ $self->{WARN}&&warn("Mandatory entity 'SMSC_PORT' was missing when creating an object of class ".
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn "Mandatory entity 'SMSC_PORT' was missing when creating an object of class Net::UCP. Object not created" 0 0 0
369 __PACKAGE__.
370 ". Object not created");
371 0 return; # Failed to instantiate this object.
372 };
373 0 ▶ $args{SMSC_PORT}=~/^\d+$/||do{
Branch: 1 branch
BranchTrueFalseTotal
$args{"SMSC_PORT"} =~ /^\d+$/ or do { $self->{"WARN"} and warn "Non-numerical data found in entity 'SMSC_PORT' when creating an object of class Net::UCP. Object not created"; return } 0 0 0
374 0 ▶ $self->{WARN}&&warn("Non-numerical data found in entity 'SMSC_PORT' when creating an object of class ".
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn "Non-numerical data found in entity 'SMSC_PORT' when creating an object of class Net::UCP. Object not created" 0 0 0
375 __PACKAGE__.
376 ". Object not created");
377 0 return; # Failed to instantiate this object.
378 };
379
380 0 $self->{SMSC_HOST} = $args{SMSC_HOST};
381 0 $self->{SMSC_PORT} = $args{SMSC_PORT};
382 0 ▶ $self->{SENDER_TEXT} = defined($args{SENDER_TEXT})&&length($args{SENDER_TEXT})?$args{SENDER_TEXT}:__PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'SENDER_TEXT'} && length $args{'SENDER_TEXT'} ? : 0 0 0
Condition0%0/3
defined $args{"SENDER_TEXT"} and length $args{"SENDER_TEXT"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"SENDER_TEXT"} and length $args{"SENDER_TEXT"}
defined $args{"SENDER_TEXT"} length $args{"SENDER_TEXT"}
Truth table0%0/3
A and B
A= defined $args{"SENDER_TEXT"}B= length $args{"SENDER_TEXT"}
ABresult
0X0
100
111
383
384 0 $self->{SRC_HOST} = $args{SRC_HOST};
385 0 $self->{SRC_PORT} = $args{SRC_PORT};
386 # itguru fix
387 0 ▶ $self->{SHORT_CODE} = defined($args{SHORT_CODE})&&length($args{SHORT_CODE})?$args{SHORT_CODE}:undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'SHORT_CODE'} && length $args{'SHORT_CODE'} ? : 0 0 0
Condition0%0/3
defined $args{"SHORT_CODE"} and length $args{"SHORT_CODE"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"SHORT_CODE"} and length $args{"SHORT_CODE"}
defined $args{"SHORT_CODE"} length $args{"SHORT_CODE"}
Truth table0%0/3
A and B
A= defined $args{"SHORT_CODE"}B= length $args{"SHORT_CODE"}
ABresult
0X0
100
111
388
389 0 $self->{SOCK} = undef;
390
391 # Some systems have not implemented alarm().
392 # On such systems, calling alarm() will create a run-time error.
393 # Determine if we dare calling alarm() or not.
394
395 #I must work on it...
396
397 0 eval{alarm(0)};
398 0 ▶ $self->{CAN_ALARM} = $@ ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
399 }
400  
401 0 $self;
402 }
403  
404  
405  
406 ##RAW MODE
407  
408 #timeout, action
409 #clear = 0,1
410 #################
411 0 ▶sub wait_in_loop {
Subroutine wait_in_loop: not called CC=10 SCAR=47.0
Pod documented
412 0 my ($self) = shift;
413 0 my %arg = @_;
414 0 my ($retval, $bits);
415
416 0 my $socket = $self->{SOCK};
417  
418 0 ▶ if (exists($arg{timeout}) and $arg{timeout} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg{"timeout"} and $arg{"timeout"} > 0) 0 0 0
Condition0%0/3
exists $arg{"timeout"} and $arg{"timeout"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"timeout"} and $arg{"timeout"} > 0
exists $arg{"timeout"} $arg{"timeout"} > 0
Truth table0%0/3
A and B
A= exists $arg{"timeout"}B= $arg{"timeout"} > 0
ABresult
0X0
100
111
419 0 ▶ $SIG{ALRM} = (exists($arg{action}) and ref($arg{action}) eq 'CODE') ? $arg{action} : \&_sig_alarm;
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'action'} && ref $arg{'action'} eq 'CODE' ? : 0 0 0
Condition0%0/3
exists $arg{"action"} and ref $arg{"action"} eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"action"} and ref $arg{"action"} eq "CODE"
exists $arg{"action"} ref $arg{"action"} eq "CODE"
Truth table0%0/3
A and B
A= exists $arg{"action"}B= ref $arg{"action"} eq "CODE"
ABresult
0X0
100
111
420 0 setitimer(ITIMER_REAL, $arg{timeout}, 0);
421 }
422
423 0 ▶ while ($socket) {
Branch: 1 branch
BranchTrueFalseTotal
if ($socket) 0 0 0
424 0 $bits = '';
425 0 vec($bits,fileno($socket),1) = 1;
426 0 $retval = 0;
427 0 $retval = select($bits,undef,undef,undef);
428
429 0 ▶ if ($retval) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retval) 0 0 0
430 0 my ($buffer,$response);
431 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$buffer eq "\3" or do { do { read $socket, $buffer, 1; $response .= $buffer } } 0 0 0
432 0 read($socket,$buffer,1);
433 0 $response.=$buffer;
434 } until ($buffer eq ETX);
435
436 0 ▶ if (exists $arg{clear}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg{"clear"}) 0 0 0
437 0 ▶ $self->remove_ucp_enclosure(\$response) if ($arg{clear});
Branch: 1 branch
BranchTrueFalseTotal
if $arg{"clear"} 0 0 0
438 }
439
440 0 setitimer(ITIMER_REAL, $arg{timeout}, 0);
441 0 return $response;
442 }
443 }
444  
445 0 setitimer(ITIMER_REAL, $arg{timeout}, 0);
446 0 return undef;
447 }
448  
449 0 ▶sub remove_ucp_enclosure {
Subroutine remove_ucp_enclosure: not called CC=1 SCAR=6.9
Pod documented
450 0 my ($self, $msg) = @_;
451 0 $$msg =~ s/@{[ETX]}|@{[STX]}//g;
452 }
453  
454 0 ▶sub add_ucp_enclosure {
Subroutine add_ucp_enclosure: not called CC=1 SCAR=6.9
Pod documented
455 0 my ($self, $msg) = @_;
456 0 $$msg = STX . $$msg . ETX;
457 }
458  
459 0 ▶sub _sig_alarm { croak "No response from SMSC\n"; }
Subroutine _sig_alarm: not called CC=1 SCAR=6.9
460  
461 #RAW functions
462 ###########################
463 1 ▶sub make_message {
Subroutine make_message: called CC=16 SCAR=48.0
Pod documented
464 1 my $self = shift;
465 1 my %arg = @_;
466
467 1 my $op = $arg{op};
468 1 my $string = undef;
469
470 0 ▶ if ($op eq "01") { $string = $self->make_01(%arg) }
Branch: 15 branches
BranchTrueFalseTotal
if ($op eq '01') { } 0 1 1
elsif ($op eq '02') { } 0 1 1
elsif ($op eq '03') { } 0 1 1
elsif ($op eq '30') { } 0 1 1
elsif ($op eq '31') { } 0 1 1
elsif ($op eq '51') { } 1 0 1
elsif ($op eq '52') { } 0 0 0
elsif ($op eq '53') { } 0 0 0
elsif ($op eq '54') { } 0 0 0
elsif ($op eq '55') { } 0 0 0
elsif ($op eq '56') { } 0 0 0
elsif ($op eq '57') { } 0 0 0
elsif ($op eq '58') { } 0 0 0
elsif ($op eq '60') { } 0 0 0
elsif ($op eq '61') { } 0 0 0
471 0 elsif ($op eq "02") { $string = $self->make_02(%arg) }
472 0 elsif ($op eq "03") { $string = $self->make_03(%arg) }
473 0 elsif ($op eq "30") { $string = $self->make_30(%arg) }
474 0 elsif ($op eq "31") { $string = $self->make_31(%arg) }
475 1 elsif ($op eq "51") { $string = $self->make_51(%arg) }
476 0 elsif ($op eq "52") { $string = $self->make_52(%arg) }
477 0 elsif ($op eq "53") { $string = $self->make_53(%arg) }
478 0 elsif ($op eq "54") { $string = $self->make_54(%arg) }
479 0 elsif ($op eq "55") { $string = $self->make_55(%arg) }
480 0 elsif ($op eq "56") { $string = $self->make_56(%arg) }
481 0 elsif ($op eq "57") { $string = $self->make_57(%arg) }
482 0 elsif ($op eq "58") { $string = $self->make_58(%arg) }
483 0 elsif ($op eq "60") { $string = $self->make_60(%arg) }
484 0 elsif ($op eq "61") { $string = $self->make_61(%arg) }
485  
486 1 return $string;
487 }
488  
489 1 ▶sub parse_message {
Subroutine parse_message: called CC=2 SCAR=7.0
Pod documented
490 1 my ($self, $resp) = @_;
491
492 1 my $ref_mess = undef;
493
494 1 ▶ if (my($optype) = $resp =~ m{^\d{2}/\d{5}/.*?/(01|02|03|30|51|52|53|54|55|56|57|58|60|61)/.*}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($optype) = $resp =~ m[^\d{2}/\d{5}/.*?/(01|02|03|30|51|52|53|54|55|56|57|58|60|61)/.*]) 1 0 1
495 1 my $parse_method = "parse_$optype";
496 1 $ref_mess = $self->$parse_method($resp);
497 }
498
499 1 return $ref_mess;
500 }
501  
502 # OPERATION TYPE 01
503 1 ▶sub parse_01 {
Subroutine parse_01: called CC=5 SCAR=20.6
Pod undocumented
504 1 my ($self, $response)=@_;
505 1 my %mess;
506  
507 1 my $resp_tmp = $response;
508 1 $resp_tmp =~ s/..$//;
509 1 $mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp);
510  
511 1 my (@ucp) = split(UCP_DELIMITER,$response);
512
513 1 $mess{trn} = $ucp[0];
514 1 $mess{len} = $ucp[1];
515 1 $mess{type} = $ucp[2];
516 1 $mess{ot} = $ucp[3];
517
518 1 ▶ if ($mess{type} eq "O") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess{'type'} eq 'O') { } 0 1 1
519 0 $mess{adc} = $ucp[4];
520 0 $mess{oadc} = $ucp[5];
521 0 $mess{ac} = $ucp[6];
522 0 $mess{mt} = $ucp[7];
523 0 ▶ $mess{nmsg} = $mess{mt} == 2 ? $ucp[8] : '';
Branch: 1 branch
BranchTrueFalseTotal
$mess{'mt'} == 2 ? : 0 0 0
524 0 ▶ $mess{amsg} = $mess{mt} == 3 ? $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[8]) : '';
Branch: 1 branch
BranchTrueFalseTotal
$mess{'mt'} == 3 ? : 0 0 0
525 0 $mess{checksum} = $ucp[9];
526 } else {
527 1 ▶ if ($ucp[4] eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucp[4] eq 'A') { } 1 0 1
528 1 $mess{ack} = $ucp[4];
529 1 $mess{sm} = $ucp[5];
530 1 $mess{checksum} = $ucp[6];
531 } else {
532 0 $mess{nack} = $ucp[4];
533 0 $mess{ec} = $ucp[5];
534 0 $mess{sm} = $ucp[6];
535 0 $mess{checksum} = $ucp[7];
536 }
537 }
538
539 1 return \%mess;
540 }
541  
542 1 ▶sub make_01 {
Subroutine make_01: called CC=18 SCAR=48.3
Pod undocumented
543 1 my ($self) = shift;
544 1 my %arg = @_;
545  
546 1 my $message_string = undef;
547
548 1 ▶ if (exists $arg{operation} and $arg{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'operation'} and $arg{'operation'} == 1) { } 1 0 1
elsif (exists $arg{'result'} and $arg{'result'} == 1) { } 0 0 0
Condition33%1/3
exists $arg{"operation"} and $arg{"operation"} == 1
!ll&&!rl&&r
001
MC/DC0%0/2
exists $arg{"operation"} and $arg{"operation"} == 1
exists $arg{"operation"} $arg{"operation"} == 1
Truth table33%1/3
A and B
A= exists $arg{"operation"}B= $arg{"operation"} == 1
ABresult
0X0
100
111
549
550 my $text = (exists $arg{nmsg} && !exists $arg{amsg})
551 ? $arg{nmsg}
552 1 ▶ : $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg});
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'nmsg'} && !exists $arg{'amsg'} ? : 0 1 1
Condition33%1/3
exists $arg{"nmsg"} and not exists $arg{"amsg"}
!ll&&!rl&&r
100
MC/DC0%0/2
exists $arg{"nmsg"} and not exists $arg{"amsg"}
exists $arg{"nmsg"} not exists $arg{"amsg"}
Truth table33%1/3
A and not(B)
A= exists $arg{"nmsg"}B= not exists $arg{"amsg"}
ABresult
0X0
100
111
553  
554 my $string =
555 (exists $arg{adc} ? $arg{adc} : '') .
556 UCP_DELIMITER .
557 (exists $arg{oadc} ? $arg{oadc} : '') .
558 UCP_DELIMITER .
559 (exists $arg{ac} ? $arg{ac} : '') .
560 UCP_DELIMITER .
561 1 ▶ (exists $arg{mt} ? $arg{mt} : '') .
Branch: 4 branches
BranchTrueFalseTotal
exists $arg{'adc'} ? : 1 0 1
exists $arg{'oadc'} ? : 1 0 1
exists $arg{'ac'} ? : 1 0 1
exists $arg{'mt'} ? : 1 0 1
562 UCP_DELIMITER .
563 $text;
564
565 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
566 UCP_DELIMITER .
567 1 $self->{OBJ_EMI_COMMON}->data_len($string) .
568 UCP_DELIMITER .
569 'O'.
570 UCP_DELIMITER .
571 '01';
572
573 $message_string = $header.
574 UCP_DELIMITER .
575 $string .
576 UCP_DELIMITER .
577 1 $self->{OBJ_EMI_COMMON}->checksum($header .
578 UCP_DELIMITER .
579 $string .
580 UCP_DELIMITER);
581  
582 ▶ } elsif (exists($arg{result}) and $arg{result} == 1) {
Condition0%0/3
exists $arg{"result"} and $arg{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"result"} and $arg{"result"} == 1
exists $arg{"result"} $arg{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg{"result"}B= $arg{"result"} == 1
ABresult
0X0
100
111
583  
584 0 ▶ if (exists $arg{ack} and $arg{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'ack'} and $arg{'ack'} ne '') { } 0 0 0
elsif (exists $arg{'nack'} and $arg{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg{"ack"} and $arg{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"ack"} and $arg{"ack"} ne ""
exists $arg{"ack"} $arg{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"ack"}B= $arg{"ack"} ne ""
ABresult
0X0
100
111
585
586 my $string =
587 $arg{ack} .
588 UCP_DELIMITER .
589 0 ▶ (exists $arg{sm} ? $arg{sm} : '');
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'sm'} ? : 0 0 0
590  
591 my $header = sprintf("%02d",$arg{trn}) .
592 UCP_DELIMITER .
593 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
594 UCP_DELIMITER .
595 'R'.
596 UCP_DELIMITER .
597 '01';
598  
599 $message_string = $header.
600 UCP_DELIMITER .
601 $string .
602 UCP_DELIMITER .
603 0 $self->{OBJ_EMI_COMMON}->checksum($header .
604 UCP_DELIMITER .
605 $string .
606 UCP_DELIMITER);
607  
608 ▶ } elsif (exists $arg{nack} and $arg{nack} ne '') {
Condition0%0/3
exists $arg{"nack"} and $arg{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nack"} and $arg{"nack"} ne ""
exists $arg{"nack"} $arg{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"nack"}B= $arg{"nack"} ne ""
ABresult
0X0
100
111
609
610 my $string =
611 $arg{nack} .
612 UCP_DELIMITER .
613 (exists $arg{ec} ? $arg{ec} : '') .
614 UCP_DELIMITER .
615 0 ▶ (exists $arg{sm} ? $arg{sm} : '');
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'ec'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
616
617 my $header = sprintf("%02d",$arg{trn}) .
618 UCP_DELIMITER .
619 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
620 UCP_DELIMITER.
621 'R'.
622 UCP_DELIMITER.
623 '01';
624  
625 $message_string = $header.
626 UCP_DELIMITER .
627 $string .
628 UCP_DELIMITER .
629 0 $self->{OBJ_EMI_COMMON}->checksum($header .
630 UCP_DELIMITER .
631 $string .
632 UCP_DELIMITER);
633 }
634 }
635
636 1 return $message_string;
637 }
638  
639 #OP 02
640 0 ▶sub parse_02 {
Subroutine parse_02: not called CC=5 SCAR=34.0
Pod undocumented
641 0 my ($self, $response)=@_;
642 0 my %mess;
643  
644 0 my $resp_tmp = $response;
645 0 $resp_tmp =~ s/..$//;
646 0 $mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp);
647
648 0 my (@ucp) = split(UCP_DELIMITER,$response);
649 #header...
650 0 $mess{trn} = $ucp[0];
651 0 $mess{len} = $ucp[1];
652 0 $mess{type} = $ucp[2];
653 0 $mess{ot} = $ucp[3];
654
655 0 ▶ if ($mess{type} eq "O") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess{'type'} eq 'O') { } 0 0 0
656 0 $mess{npl} = $ucp[4];
657 0 $mess{rads} = $ucp[5];
658 0 $mess{oadc} = $ucp[6];
659 0 $mess{ac} = $ucp[7];
660 0 $mess{mt} = $ucp[8];
661 0 ▶ $mess{nmsg} = $mess{mt} == 2 ? $ucp[9] : '';
Branch: 1 branch
BranchTrueFalseTotal
$mess{'mt'} == 2 ? : 0 0 0
662 0 ▶ $mess{amsg} = $mess{mt} == 3 ? $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[9]) : '';
Branch: 1 branch
BranchTrueFalseTotal
$mess{'mt'} == 3 ? : 0 0 0
663 0 $mess{checksum} = $ucp[10];
664 } else {
665 0 ▶ if ($ucp[4] eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucp[4] eq 'A') { } 0 0 0
666 0 $mess{ack} = $ucp[4];
667 0 $mess{sm} = $ucp[5];
668 0 $mess{checksum} = $ucp[6];
669 } else {
670 0 $mess{nack} = $ucp[4];
671 0 $mess{ec} = $ucp[5];
672 0 $mess{sm} = $ucp[6];
673 0 $mess{checksum} = $ucp[7];
674 }
675 }
676
677 0 return \%mess;
678 }
679  
680  
681 1 ▶sub make_02 {
Subroutine make_02: called CC=19 SCAR=49.0
Pod undocumented
682 1 my ($self) = shift;
683 1 my %arg = @_;
684  
685 1 my $message_string = undef;
686  
687 1 ▶ if (exists $arg{operation} and $arg{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'operation'} and $arg{'operation'} == 1) { } 1 0 1
elsif (exists $arg{'result'} and $arg{'result'} == 1) { } 0 0 0
Condition33%1/3
exists $arg{"operation"} and $arg{"operation"} == 1
!ll&&!rl&&r
001
MC/DC0%0/2
exists $arg{"operation"} and $arg{"operation"} == 1
exists $arg{"operation"} $arg{"operation"} == 1
Truth table33%1/3
A and B
A= exists $arg{"operation"}B= $arg{"operation"} == 1
ABresult
0X0
100
111
688  
689 my $text = (exists $arg{nmsg} && !exists $arg{amsg})
690 ? $arg{nmsg}
691 1 ▶ : $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg});
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'nmsg'} && !exists $arg{'amsg'} ? : 0 1 1
Condition33%1/3
exists $arg{"nmsg"} and not exists $arg{"amsg"}
!ll&&!rl&&r
100
MC/DC0%0/2
exists $arg{"nmsg"} and not exists $arg{"amsg"}
exists $arg{"nmsg"} not exists $arg{"amsg"}
Truth table33%1/3
A and not(B)
A= exists $arg{"nmsg"}B= not exists $arg{"amsg"}
ABresult
0X0
100
111
692  
693 my $string =
694 (exists $arg{npl} ? $arg{npl} : '') .
695 UCP_DELIMITER .
696 (exists $arg{rads} ? $arg{rads} : '') .
697 UCP_DELIMITER .
698 (exists $arg{oadc} ? $arg{oadc} : '') .
699 UCP_DELIMITER .
700 (exists $arg{ac} ? $arg{ac} : '') .
701 UCP_DELIMITER .
702 1 ▶ (exists $arg{mt} ? $arg{mt} : '') .
Branch: 5 branches
BranchTrueFalseTotal
exists $arg{'npl'} ? : 1 0 1
exists $arg{'rads'} ? : 1 0 1
exists $arg{'oadc'} ? : 1 0 1
exists $arg{'ac'} ? : 1 0 1
exists $arg{'mt'} ? : 1 0 1
703 UCP_DELIMITER .
704 $text;
705  
706 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
707 UCP_DELIMITER .
708 1 $self->{OBJ_EMI_COMMON}->data_len($string) .
709 UCP_DELIMITER.
710 'O'.
711 UCP_DELIMITER.
712 '02';
713
714 $message_string = $header.
715 UCP_DELIMITER .
716 $string .
717 UCP_DELIMITER .
718 1 $self->{OBJ_EMI_COMMON}->checksum($header .
719 UCP_DELIMITER .
720 $string .
721 UCP_DELIMITER);
722
723 ▶ } elsif (exists($arg{result}) and $arg{result} == 1) {
Condition0%0/3
exists $arg{"result"} and $arg{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"result"} and $arg{"result"} == 1
exists $arg{"result"} $arg{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg{"result"}B= $arg{"result"} == 1
ABresult
0X0
100
111
724  
725 0 ▶ if (exists $arg{ack} and $arg{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'ack'} and $arg{'ack'} ne '') { } 0 0 0
elsif (exists $arg{'nack'} and $arg{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg{"ack"} and $arg{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"ack"} and $arg{"ack"} ne ""
exists $arg{"ack"} $arg{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"ack"}B= $arg{"ack"} ne ""
ABresult
0X0
100
111
726
727 my $string =
728 $arg{ack} .
729 UCP_DELIMITER .
730 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'sm'} ? : 0 0 0
731  
732 my $header = sprintf("%02d",$arg{trn}) .
733 UCP_DELIMITER .
734 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
735 UCP_DELIMITER.
736 'R'.
737 UCP_DELIMITER.
738 '02';
739  
740 $message_string = $header.
741 UCP_DELIMITER .
742 $string .
743 UCP_DELIMITER .
744 0 $self->{OBJ_EMI_COMMON}->checksum($header .
745 UCP_DELIMITER .
746 $string .
747 UCP_DELIMITER);
748  
749 ▶ } elsif (exists $arg{nack} and $arg{nack} ne '') {
Condition0%0/3
exists $arg{"nack"} and $arg{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nack"} and $arg{"nack"} ne ""
exists $arg{"nack"} $arg{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"nack"}B= $arg{"nack"} ne ""
ABresult
0X0
100
111
750
751 my $string =
752 $arg{nack} .
753 UCP_DELIMITER .
754 (exists $arg{ec} ? $arg{ec} : '') .
755 UCP_DELIMITER .
756 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'ec'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
757  
758 my $header = sprintf("%02d",$arg{trn}) .
759 UCP_DELIMITER .
760 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
761 UCP_DELIMITER.
762 'R'.
763 UCP_DELIMITER.
764 '02';
765  
766 $message_string = $header.
767 UCP_DELIMITER .
768 $string .
769 UCP_DELIMITER .
770 0 $self->{OBJ_EMI_COMMON}->checksum($header .
771 UCP_DELIMITER .
772 $string .
773 UCP_DELIMITER);
774 }
775 }
776
777 1 return $message_string;
778 }
779  
780  
781 #OP 03
782 0 ▶sub parse_03 {
Subroutine parse_03: not called CC=5 SCAR=34.0
Pod undocumented
783 0 my ($self, $response)=@_;
784 0 my %mess ;
785  
786 0 my $resp_tmp = $response;
787 0 $resp_tmp =~ s/..$//;
788 0 $mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp);
789
790 0 my (@ucp) = split(UCP_DELIMITER,$response);
791 #header...
792 0 $mess{trn} = $ucp[0];
793 0 $mess{len} = $ucp[1];
794 0 $mess{type} = $ucp[2];
795 0 $mess{ot} = $ucp[3];
796
797 0 ▶ if ($mess{type} eq "O") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess{'type'} eq 'O') { } 0 0 0
798 0 $mess{rad} = $ucp[4];
799 0 $mess{oadc} = $ucp[5];
800 0 $mess{ac} = $ucp[6];
801 0 $mess{npl} = $ucp[7]; #must be 0
802 0 $mess{gas} = $ucp[8]; #empty if npl 0
803 0 $mess{rp} = $ucp[9];
804 0 $mess{pr} = $ucp[10];
805 0 $mess{lpr} = $ucp[11];
806 0 $mess{ur} = $ucp[12];
807 0 $mess{lur} = $ucp[13];
808 0 $mess{rc} = $ucp[14];
809 0 $mess{lrc} = $ucp[15];
810 0 $mess{dd} = $ucp[16];
811 0 $mess{ddt} = $ucp[17];
812 0 $mess{mt} = $ucp[18];
813 0 ▶ $mess{nmsg} = $mess{mt} == 2 ? $ucp[19] : '';
Branch: 1 branch
BranchTrueFalseTotal
$mess{'mt'} == 2 ? : 0 0 0
814 0 ▶ $mess{amsg} = $mess{mt} == 3 ? $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[19]) : '';
Branch: 1 branch
BranchTrueFalseTotal
$mess{'mt'} == 3 ? : 0 0 0
815 0 $mess{checksum} = $ucp[20];
816 } else {
817 0 ▶ if ($ucp[4] eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucp[4] eq 'A') { } 0 0 0
818 0 $mess{ack} = $ucp[4];
819 0 $mess{sm} = $ucp[5];
820 0 $mess{checksum} = $ucp[6];
821 } else {
822 0 $mess{nack} = $ucp[4];
823 0 $mess{ec} = $ucp[5];
824 0 $mess{sm} = $ucp[6];
825 0 $mess{checksum} = $ucp[7];
826 }
827 }
828
829 0 return \%mess;
830 }
831  
832  
833 0 ▶sub make_03 {
Subroutine make_03: not called CC=29 SCAR=67.7
Pod undocumented
834 0 my ($self) = shift;
835 0 my %arg = @_;
836  
837 0 my $message_string = undef;
838  
839 0 ▶ if (exists $arg{operation} and $arg{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'operation'} and $arg{'operation'} == 1) { } 0 0 0
elsif (exists $arg{'result'} and $arg{'result'} == 1) { } 0 0 0
Condition0%0/3
exists $arg{"operation"} and $arg{"operation"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"operation"} and $arg{"operation"} == 1
exists $arg{"operation"} $arg{"operation"} == 1
Truth table0%0/3
A and B
A= exists $arg{"operation"}B= $arg{"operation"} == 1
ABresult
0X0
100
111
840  
841 my $text = (exists $arg{nmsg} && !exists $arg{amsg})
842 ? $arg{nmsg}
843 0 ▶ : $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg});
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'nmsg'} && !exists $arg{'amsg'} ? : 0 0 0
Condition0%0/3
exists $arg{"nmsg"} and not exists $arg{"amsg"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nmsg"} and not exists $arg{"amsg"}
exists $arg{"nmsg"} not exists $arg{"amsg"}
Truth table0%0/3
A and not(B)
A= exists $arg{"nmsg"}B= not exists $arg{"amsg"}
ABresult
0X0
100
111
844  
845 my $string =
846 (exists $arg{rad} ? $arg{rad} : '') .
847 UCP_DELIMITER .
848 (exists $arg{oadc} ? $arg{oadc} : '') .
849 UCP_DELIMITER .
850 (exists $arg{ac} ? $arg{ac} : '') .
851 UCP_DELIMITER .
852 (exists $arg{npl} ? $arg{npl} : '') .
853 UCP_DELIMITER .
854 (exists $arg{gas} ? $arg{gas} : '') .
855 UCP_DELIMITER .
856 (exists $arg{rp} ? $arg{rp} : '') .
857 UCP_DELIMITER .
858 (exists $arg{pr} ? $arg{pr} : '') .
859 UCP_DELIMITER .
860 (exists $arg{lpr} ? $arg{lpr} : '') .
861 UCP_DELIMITER .
862 (exists $arg{ur} ? $arg{ur} : '') .
863 UCP_DELIMITER .
864 (exists $arg{lur} ? $arg{lur} : '') .
865 UCP_DELIMITER .
866 (exists $arg{rc} ? $arg{rc} : '') .
867 UCP_DELIMITER .
868 (exists $arg{lrc} ? $arg{lrc} : '') .
869 UCP_DELIMITER .
870 (exists $arg{dd} ? $arg{dd} : '') .
871 UCP_DELIMITER .
872 (exists $arg{ddt} ? $arg{ddt} : '') .
873 UCP_DELIMITER .
874 0 ▶ (exists $arg{mt} ? $arg{mt} : '') .
Branch: 15 branches
BranchTrueFalseTotal
exists $arg{'rad'} ? : 0 0 0
exists $arg{'oadc'} ? : 0 0 0
exists $arg{'ac'} ? : 0 0 0
exists $arg{'npl'} ? : 0 0 0
exists $arg{'gas'} ? : 0 0 0
exists $arg{'rp'} ? : 0 0 0
exists $arg{'pr'} ? : 0 0 0
exists $arg{'lpr'} ? : 0 0 0
exists $arg{'ur'} ? : 0 0 0
exists $arg{'lur'} ? : 0 0 0
exists $arg{'rc'} ? : 0 0 0
exists $arg{'lrc'} ? : 0 0 0
exists $arg{'dd'} ? : 0 0 0
exists $arg{'ddt'} ? : 0 0 0
exists $arg{'mt'} ? : 0 0 0
875 UCP_DELIMITER .
876 $text;
877  
878 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
879 UCP_DELIMITER .
880 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
881 UCP_DELIMITER.
882 'O'.
883 UCP_DELIMITER.
884 '03';
885
886 $message_string = $header.
887 UCP_DELIMITER .
888 $string .
889 UCP_DELIMITER .
890 0 $self->{OBJ_EMI_COMMON}->checksum($header .
891 UCP_DELIMITER .
892 $string .
893 UCP_DELIMITER);
894  
895 ▶ } elsif (exists($arg{result}) and $arg{result} == 1) {
Condition0%0/3
exists $arg{"result"} and $arg{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"result"} and $arg{"result"} == 1
exists $arg{"result"} $arg{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg{"result"}B= $arg{"result"} == 1
ABresult
0X0
100
111
896  
897 0 ▶ if (exists $arg{ack} and $arg{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'ack'} and $arg{'ack'} ne '') { } 0 0 0
elsif (exists $arg{'nack'} and $arg{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg{"ack"} and $arg{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"ack"} and $arg{"ack"} ne ""
exists $arg{"ack"} $arg{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"ack"}B= $arg{"ack"} ne ""
ABresult
0X0
100
111
898
899 my $string =
900 $arg{ack} .
901 UCP_DELIMITER .
902 0 ▶ (exists $arg{sm} ? $arg{sm} : '');
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'sm'} ? : 0 0 0
903  
904 my $header = sprintf("%02d",$arg{trn}) .
905 UCP_DELIMITER .
906 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
907 UCP_DELIMITER.
908 'R'.
909 UCP_DELIMITER.
910 '03';
911  
912 $message_string = $header.
913 UCP_DELIMITER .
914 $string .
915 UCP_DELIMITER .
916 0 $self->{OBJ_EMI_COMMON}->checksum($header .
917 UCP_DELIMITER .
918 $string .
919 UCP_DELIMITER);
920  
921 ▶ } elsif (exists $arg{nack} and $arg{nack} ne '') {
Condition0%0/3
exists $arg{"nack"} and $arg{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nack"} and $arg{"nack"} ne ""
exists $arg{"nack"} $arg{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"nack"}B= $arg{"nack"} ne ""
ABresult
0X0
100
111
922
923 my $string =
924 $arg{nack} .
925 UCP_DELIMITER .
926 (exists $arg{ec} ? $arg{ec} : '') .
927 UCP_DELIMITER .
928 0 ▶ (exists $arg{sm} ? $arg{sm} : '');
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'ec'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
929  
930 my $header = sprintf("%02d",$arg{trn}) .
931 UCP_DELIMITER .
932 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
933 UCP_DELIMITER.
934 'R'.
935 UCP_DELIMITER.
936 '03';
937  
938 $message_string = $header.
939 UCP_DELIMITER .
940 $string .
941 UCP_DELIMITER .
942 0 $self->{OBJ_EMI_COMMON}->checksum($header .
943 UCP_DELIMITER .
944 $string .
945 UCP_DELIMITER);
946 }
947 }
948
949 0 return $message_string;
950 }
951  
952  
953 #OP 30
954 0 ▶sub parse_30 {
Subroutine parse_30: not called CC=3 SCAR=24.8
Pod undocumented
955 0 my ($self, $response)=@_;
956 0 my %mess;
957  
958 0 my $resp_tmp = $response;
959 0 $resp_tmp =~ s/..$//;
960 0 $mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp);
961  
962 0 my (@ucp) = split(UCP_DELIMITER,$response);
963 #header...
964 0 $mess{trn} = $ucp[0];
965 0 $mess{len} = $ucp[1];
966 0 $mess{type} = $ucp[2];
967 0 $mess{ot} = $ucp[3];
968
969 0 ▶ if ($mess{type} eq "O") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess{'type'} eq 'O') { } 0 0 0
970 0 $mess{adc} = $ucp[4];
971 0 $mess{oadc} = $ucp[5];
972 0 $mess{ac} = $ucp[6];
973 0 $mess{nrq} = $ucp[7];
974 0 $mess{nad} = $ucp[8];
975 0 $mess{npid} = $ucp[9];
976 0 $mess{dd} = $ucp[10];
977 0 $mess{ddt} = $ucp[11];
978 0 $mess{vp} = $ucp[12];
979 0 $mess{amsg} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[13]);
980 0 $mess{checksum} = $ucp[14];
981 } else {
982 0 ▶ if ($ucp[4] eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucp[4] eq 'A') { } 0 0 0
983 0 $mess{ack} = $ucp[4];
984 0 $mess{mvp} = $ucp[5];
985 0 $mess{sm} = $ucp[6];
986 0 $mess{checksum} = $ucp[7];
987 } else {
988 0 $mess{nack} = $ucp[4];
989 0 $mess{ec} = $ucp[5];
990 0 $mess{sm} = $ucp[6];
991 0 $mess{checksum} = $ucp[7];
992 }
993 }
994
995 0 return \%mess;
996 }
997  
998  
999 0 ▶sub make_30 {
Subroutine make_30: not called CC=22 SCAR=62.3
Pod undocumented
1000 0 my ($self) = shift;
1001 0 my %arg = @_;
1002  
1003 0 my $message_string = undef;
1004  
1005 0 ▶ if (exists $arg{operation} and $arg{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'operation'} and $arg{'operation'} == 1) { } 0 0 0
elsif (exists $arg{'result'} and $arg{'result'} == 1) { } 0 0 0
Condition0%0/3
exists $arg{"operation"} and $arg{"operation"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"operation"} and $arg{"operation"} == 1
exists $arg{"operation"} $arg{"operation"} == 1
Truth table0%0/3
A and B
A= exists $arg{"operation"}B= $arg{"operation"} == 1
ABresult
0X0
100
111
1006  
1007 0 my $text = $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg});
1008  
1009 my $string =
1010 (exists $arg{adc} ? $arg{adc} : '') .
1011 UCP_DELIMITER .
1012 (exists $arg{oadc} ? $arg{oadc} : '') .
1013 UCP_DELIMITER .
1014 (exists $arg{ac} ? $arg{ac} : '') .
1015 UCP_DELIMITER .
1016 (exists $arg{nrq} ? $arg{nrq} : '') .
1017 UCP_DELIMITER .
1018 (exists $arg{nad} ? $arg{nad} : '') .
1019 UCP_DELIMITER .
1020 (exists $arg{npid} ? $arg{npid} : '') .
1021 UCP_DELIMITER .
1022 (exists $arg{dd} ? $arg{dd} : '') .
1023 UCP_DELIMITER .
1024 (exists $arg{ddt} ? $arg{ddt} : '') .
1025 UCP_DELIMITER .
1026 0 ▶ (exists $arg{vp} ? $arg{vp} : '') .
Branch: 9 branches
BranchTrueFalseTotal
exists $arg{'adc'} ? : 0 0 0
exists $arg{'oadc'} ? : 0 0 0
exists $arg{'ac'} ? : 0 0 0
exists $arg{'nrq'} ? : 0 0 0
exists $arg{'nad'} ? : 0 0 0
exists $arg{'npid'} ? : 0 0 0
exists $arg{'dd'} ? : 0 0 0
exists $arg{'ddt'} ? : 0 0 0
exists $arg{'vp'} ? : 0 0 0
1027 UCP_DELIMITER .
1028 $text;
1029  
1030 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
1031 UCP_DELIMITER .
1032 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1033 UCP_DELIMITER.
1034 'O'.
1035 UCP_DELIMITER.
1036 '30';
1037
1038 $message_string = $header.
1039 UCP_DELIMITER .
1040 $string .
1041 UCP_DELIMITER .
1042 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1043 UCP_DELIMITER .
1044 $string .
1045 UCP_DELIMITER);
1046  
1047 ▶ } elsif (exists($arg{result}) and $arg{result} == 1) {
Condition0%0/3
exists $arg{"result"} and $arg{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"result"} and $arg{"result"} == 1
exists $arg{"result"} $arg{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg{"result"}B= $arg{"result"} == 1
ABresult
0X0
100
111
1048  
1049 0 ▶ if (exists $arg{ack} and $arg{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'ack'} and $arg{'ack'} ne '') { } 0 0 0
elsif (exists $arg{'nack'} and $arg{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg{"ack"} and $arg{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"ack"} and $arg{"ack"} ne ""
exists $arg{"ack"} $arg{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"ack"}B= $arg{"ack"} ne ""
ABresult
0X0
100
111
1050
1051 my $string =
1052 $arg{ack} .
1053 UCP_DELIMITER .
1054 (exists $arg{mvp} ? $arg{mvp} : '') .
1055 UCP_DELIMITER .
1056 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'mvp'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
1057  
1058 my $header = sprintf("%02d",$arg{trn}) .
1059 UCP_DELIMITER .
1060 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1061 UCP_DELIMITER.
1062 'R'.
1063 UCP_DELIMITER.
1064 '30';
1065  
1066 $message_string = $header.
1067 UCP_DELIMITER .
1068 $string .
1069 UCP_DELIMITER .
1070 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1071 UCP_DELIMITER .
1072 $string .
1073 UCP_DELIMITER);
1074
1075 ▶ } elsif (exists $arg{nack} and $arg{nack} ne '') {
Condition0%0/3
exists $arg{"nack"} and $arg{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nack"} and $arg{"nack"} ne ""
exists $arg{"nack"} $arg{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"nack"}B= $arg{"nack"} ne ""
ABresult
0X0
100
111
1076
1077 my $string =
1078 $arg{nack} .
1079 UCP_DELIMITER .
1080 (exists $arg{ec} ? $arg{ec} : '') .
1081 UCP_DELIMITER .
1082 0 ▶ (exists $arg{sm} ? $arg{sm} : '');
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'ec'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
1083  
1084 my $header = sprintf("%02d",$arg{trn}) .
1085 UCP_DELIMITER .
1086 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1087 UCP_DELIMITER.
1088 'R'.
1089 UCP_DELIMITER.
1090 '30';
1091  
1092 $message_string = $header.
1093 UCP_DELIMITER .
1094 $string .
1095 UCP_DELIMITER .
1096 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1097 UCP_DELIMITER .
1098 $string .
1099 UCP_DELIMITER);
1100 }
1101 }
1102
1103 0 return $message_string;
1104 }
1105  
1106  
1107 #OP 31
1108 0 ▶sub parse_31 {
Subroutine parse_31: not called CC=3 SCAR=24.8
Pod undocumented
1109 0 my ($self, $response)=@_;
1110 0 my %mess;
1111  
1112 0 my $resp_tmp = $response;
1113 0 $resp_tmp =~ s/..$//;
1114 0 $mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp);
1115  
1116 0 my (@ucp) = split(UCP_DELIMITER,$response);
1117 #header...
1118 0 $mess{trn} = $ucp[0];
1119 0 $mess{len} = $ucp[1];
1120 0 $mess{type} = $ucp[2];
1121 0 $mess{ot} = $ucp[3];
1122
1123 0 ▶ if ($mess{type} eq "O") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess{'type'} eq 'O') { } 0 0 0
1124 0 $mess{adc} = $ucp[4];
1125 0 $mess{pid} = $ucp[5];
1126 0 $mess{checksum} = $ucp[6];
1127 } else {
1128 0 ▶ if ($ucp[4] eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucp[4] eq 'A') { } 0 0 0
1129 0 $mess{ack} = $ucp[4];
1130 0 $mess{sm} = $ucp[5];
1131 0 $mess{checksum} = $ucp[6];
1132 } else {
1133 0 $mess{nack} = $ucp[4];
1134 0 $mess{ec} = $ucp[5];
1135 0 $mess{sm} = $ucp[6];
1136 0 $mess{checksum} = $ucp[7];
1137 }
1138 }
1139
1140 0 return \%mess;
1141 }
1142  
1143  
1144 0 ▶sub make_31 {
Subroutine make_31: not called CC=14 SCAR=53.5
Pod undocumented
1145 0 my ($self) = shift;
1146 0 my %arg = @_;
1147  
1148 0 my $message_string = undef;
1149  
1150 0 ▶ if (exists $arg{operation} and $arg{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'operation'} and $arg{'operation'} == 1) { } 0 0 0
elsif (exists $arg{'result'} and $arg{'result'} == 1) { } 0 0 0
Condition0%0/3
exists $arg{"operation"} and $arg{"operation"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"operation"} and $arg{"operation"} == 1
exists $arg{"operation"} $arg{"operation"} == 1
Truth table0%0/3
A and B
A= exists $arg{"operation"}B= $arg{"operation"} == 1
ABresult
0X0
100
111
1151  
1152 my $string =
1153 (exists $arg{adc} ? $arg{adc} : '') .
1154 UCP_DELIMITER .
1155 0 ▶ (exists $arg{pid} ? $arg{pid} : '') ;
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'adc'} ? : 0 0 0
exists $arg{'pid'} ? : 0 0 0
1156
1157 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
1158 UCP_DELIMITER .
1159 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1160 UCP_DELIMITER.
1161 'O'.
1162 UCP_DELIMITER.
1163 '31';
1164
1165 $message_string = $header.
1166 UCP_DELIMITER .
1167 $string .
1168 UCP_DELIMITER .
1169 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1170 UCP_DELIMITER .
1171 $string .
1172 UCP_DELIMITER);
1173  
1174 ▶ } elsif (exists($arg{result}) and $arg{result} == 1) {
Condition0%0/3
exists $arg{"result"} and $arg{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"result"} and $arg{"result"} == 1
exists $arg{"result"} $arg{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg{"result"}B= $arg{"result"} == 1
ABresult
0X0
100
111
1175  
1176 0 ▶ if (exists $arg{ack} and $arg{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'ack'} and $arg{'ack'} ne '') { } 0 0 0
elsif (exists $arg{'nack'} and $arg{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg{"ack"} and $arg{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"ack"} and $arg{"ack"} ne ""
exists $arg{"ack"} $arg{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"ack"}B= $arg{"ack"} ne ""
ABresult
0X0
100
111
1177
1178 my $string =
1179 $arg{ack} .
1180 UCP_DELIMITER .
1181 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'sm'} ? : 0 0 0
1182  
1183 my $header = sprintf("%02d",$arg{trn}) .
1184 UCP_DELIMITER .
1185 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1186 UCP_DELIMITER.
1187 'R'.
1188 UCP_DELIMITER.
1189 '31';
1190  
1191 $message_string = $header.
1192 UCP_DELIMITER .
1193 $string .
1194 UCP_DELIMITER .
1195 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1196 UCP_DELIMITER .
1197 $string .
1198 UCP_DELIMITER);
1199
1200 ▶ } elsif (exists $arg{nack} and $arg{nack} ne '') {
Condition0%0/3
exists $arg{"nack"} and $arg{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nack"} and $arg{"nack"} ne ""
exists $arg{"nack"} $arg{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"nack"}B= $arg{"nack"} ne ""
ABresult
0X0
100
111
1201
1202 my $string =
1203 $arg{nack} .
1204 UCP_DELIMITER .
1205 (exists $arg{ec} ? $arg{ec} : '') .
1206 UCP_DELIMITER .
1207 0 ▶ (exists $arg{sm} ? $arg{sm} : '');
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'ec'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
1208  
1209 my $header = sprintf("%02d",$arg{trn}) .
1210 UCP_DELIMITER .
1211 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1212 UCP_DELIMITER.
1213 'R'.
1214 UCP_DELIMITER.
1215 '31';
1216  
1217 $message_string = $header.
1218 UCP_DELIMITER .
1219 $string .
1220 UCP_DELIMITER .
1221 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1222 UCP_DELIMITER .
1223 $string .
1224 UCP_DELIMITER);
1225 }
1226 }
1227
1228 0 return $message_string;
1229 }
1230  
1231  
1232 #OP 5x abstract
1233 0 ▶sub _parse_5x {
Subroutine _parse_5x: not called CC=10 SCAR=47.0
1234 0 my ($self, $response)=@_;
1235 0 my %mess;
1236  
1237 0 my $resp_tmp = $response;
1238 0 $resp_tmp =~ s/..$//;
1239 0 $mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp);
1240  
1241 0 my (@ucp) = split(UCP_DELIMITER,$response);
1242 #header...
1243 0 $mess{trn} = $ucp[0];
1244 0 $mess{len} = $ucp[1];
1245 0 $mess{type} = $ucp[2];
1246 0 $mess{ot} = $ucp[3];
1247
1248 0 ▶ if ($mess{type} eq "O") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess{'type'} eq 'O') { } 0 0 0
1249 0 $mess{adc} = $ucp[4];
1250 0 $mess{otoa} = $ucp[32];
1251 0 ▶ $mess{oadc} = ($mess{otoa} eq "5039") ? $self->{OBJ_EMI_COMMON}->decode_7bit(substr($ucp[5],2)) : $ucp[5];
Branch: 1 branch
BranchTrueFalseTotal
$mess{'otoa'} eq '5039' ? : 0 0 0
1252 0 $mess{ac} = $ucp[6];
1253 0 $mess{nrq} = $ucp[7];
1254 0 $mess{nadc} = $ucp[8];
1255 0 $mess{nt} = $ucp[9];
1256 0 $mess{npid} = $ucp[10];
1257 0 $mess{lrq} = $ucp[11];
1258 0 $mess{lrad} = $ucp[12];
1259 0 $mess{lpid} = $ucp[13];
1260 0 $mess{dd} = $ucp[14];
1261 0 $mess{ddt} = $ucp[15];
1262 0 $mess{vp} = $ucp[16];
1263 0 $mess{rpid} = $ucp[17];
1264 0 $mess{scts} = $ucp[18];
1265 0 $mess{dst} = $ucp[19];
1266 0 $mess{rsn} = $ucp[20];
1267 0 $mess{dscts} = $ucp[21];
1268 0 $mess{mt} = $ucp[22];
1269 0 $mess{nb} = $ucp[23];
1270 0 ▶ $mess{nmsg} = $ucp[24] if ($mess{mt} && $mess{mt} == 2);
Branch: 1 branch
BranchTrueFalseTotal
if $mess{"mt"} and $mess{"mt"} == 2 0 0 0
Condition0%0/3
$mess{"mt"} and $mess{"mt"} == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$mess{"mt"} and $mess{"mt"} == 2
$mess{"mt"} $mess{"mt"} == 2
Truth table0%0/3
A and B
A= $mess{"mt"}B= $mess{"mt"} == 2
ABresult
0X0
100
111
1271 0 ▶ $mess{amsg} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[24]) if ($mess{mt} && $mess{mt} == 3);
Branch: 1 branch
BranchTrueFalseTotal
if $mess{"mt"} and $mess{"mt"} == 3 0 0 0
Condition0%0/3
$mess{"mt"} and $mess{"mt"} == 3
!ll&&!rl&&r
000
MC/DC0%0/2
$mess{"mt"} and $mess{"mt"} == 3
$mess{"mt"} $mess{"mt"} == 3
Truth table0%0/3
A and B
A= $mess{"mt"}B= $mess{"mt"} == 3
ABresult
0X0
100
111
1272 0 ▶ $mess{tmsg} = $ucp[24] if ($mess{mt} && $mess{mt} == 4);
Branch: 1 branch
BranchTrueFalseTotal
if $mess{"mt"} and $mess{"mt"} == 4 0 0 0
Condition0%0/3
$mess{"mt"} and $mess{"mt"} == 4
!ll&&!rl&&r
000
MC/DC0%0/2
$mess{"mt"} and $mess{"mt"} == 4
$mess{"mt"} $mess{"mt"} == 4
Truth table0%0/3
A and B
A= $mess{"mt"}B= $mess{"mt"} == 4
ABresult
0X0
100
111
1273 0 $mess{mms} = $ucp[25];
1274 0 $mess{pr} = $ucp[26];
1275 0 $mess{dcs} = $ucp[27];
1276 0 $mess{mcls} = $ucp[28];
1277 0 $mess{rpi} = $ucp[29];
1278 0 $mess{cpg} = $ucp[30];
1279 0 $mess{rply} = $ucp[31];
1280 0 $mess{hplmn} = $ucp[33];
1281 0 $mess{xser} = $ucp[34];
1282 0 $mess{res4} = $ucp[35];
1283 0 $mess{res5} = $ucp[36];
1284 0 $mess{checksum} = $ucp[37];
1285 } else {
1286 0 ▶ if ($ucp[4] eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucp[4] eq 'A') { } 0 0 0
1287 0 $mess{ack} = $ucp[4];
1288 0 $mess{mvp} = $ucp[5];
1289 0 $mess{sm} = $ucp[6];
1290 0 $mess{checksum} = $ucp[7];
1291 } else {
1292 0 $mess{nack} = $ucp[4];
1293 0 $mess{ec} = $ucp[5];
1294 0 $mess{sm} = $ucp[6];
1295 0 $mess{checksum} = $ucp[7];
1296 }
1297 }
1298
1299 0 return \%mess;
1300  
1301 }
1302  
1303 1 ▶sub _make_5x {
Subroutine _make_5x: called CC=49 SCAR=63.1
1304 1 my ($self) = shift;
1305 1 my $arg = shift;
1306 1 my $op_type = shift;
1307
1308 1 my $message_string = undef;
1309  
1310 1 ▶ if (exists $arg->{operation} and $arg->{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg->{'operation'} and $arg->{'operation'} == 1) { } 1 0 1
elsif (exists $arg->{'result'} and $arg->{'result'} == 1) { } 0 0 0
Condition33%1/3
exists $arg->{"operation"} and $arg->{"operation"} == 1
!ll&&!rl&&r
001
MC/DC0%0/2
exists $arg->{"operation"} and $arg->{"operation"} == 1
exists $arg->{"operation"} $arg->{"operation"} == 1
Truth table33%1/3
A and B
A= exists $arg->{"operation"}B= $arg->{"operation"} == 1
ABresult
0X0
100
111
1311  
1312 1 my $text = '';
1313 1 my $from = '';
1314  
1315 1 ▶ if (exists $arg->{amsg}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg->{'amsg'}) { } 1 0 1
1316 1 $text = $self->{OBJ_EMI_COMMON}->ia5_encode($arg->{amsg});
1317 } else {
1318 0 ▶ $text = exists $arg->{nmsg} && !exists $arg->{tmsg} ? $arg->{nmsg} : $arg->{tmsg};
Branch: 1 branch
BranchTrueFalseTotal
exists $arg->{'nmsg'} && !exists $arg->{'tmsg'} ? : 0 0 0
Condition0%0/3
exists $arg->{"nmsg"} and not exists $arg->{"tmsg"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg->{"nmsg"} and not exists $arg->{"tmsg"}
exists $arg->{"nmsg"} not exists $arg->{"tmsg"}
Truth table0%0/3
A and not(B)
A= exists $arg->{"nmsg"}B= not exists $arg->{"tmsg"}
ABresult
0X0
100
111
1319 }
1320
1321 $from = $arg->{otoa} eq '5039'
1322 ? $self->{OBJ_EMI_COMMON}->encode_7bit($arg->{oadc})
1323 : $arg->{oadc}
1324 1 ▶ if exists $arg->{otoa} ;
Branch: 2 branches
BranchTrueFalseTotal
if exists $arg->{"otoa"} 1 0 1
$arg->{'otoa'} eq '5039' ? : 1 0 1
1325  
1326 my $string =
1327 (exists $arg->{adc} ? $arg->{adc} : '') .
1328 UCP_DELIMITER .
1329 $from .
1330 UCP_DELIMITER .
1331 (exists $arg->{ac} ? $arg->{ac} : '') .
1332 UCP_DELIMITER .
1333 (exists $arg->{nrq} ? $arg->{nrq} : '') .
1334 UCP_DELIMITER .
1335 (exists $arg->{nadc} ? $arg->{nadc} : '') .
1336 UCP_DELIMITER .
1337 (exists $arg->{nt} ? $arg->{nt} : '') .
1338 UCP_DELIMITER .
1339 (exists $arg->{npid} ? $arg->{npid} : '') .
1340 UCP_DELIMITER .
1341 (exists $arg->{lrq} ? $arg->{lrq} : '') .
1342 UCP_DELIMITER .
1343 (exists $arg->{lrad} ? $arg->{lrad} : '') .
1344 UCP_DELIMITER .
1345 (exists $arg->{lpid} ? $arg->{lpid} : '') .
1346 UCP_DELIMITER .
1347 (exists $arg->{dd} ? $arg->{dd} : '') .
1348 UCP_DELIMITER .
1349 (exists $arg->{ddt} ? $arg->{ddt} : '') .
1350 UCP_DELIMITER .
1351 (exists $arg->{vp} ? $arg->{vp} : '') .
1352 UCP_DELIMITER .
1353 (exists $arg->{rpid} ? $arg->{rpid} : '') .
1354 UCP_DELIMITER .
1355 (exists $arg->{scts} ? $arg->{scts} : '') .
1356 UCP_DELIMITER .
1357 (exists $arg->{dst} ? $arg->{dst} : '') .
1358 UCP_DELIMITER .
1359 (exists $arg->{rsn} ? $arg->{rsn} : '') .
1360 UCP_DELIMITER .
1361 (exists $arg->{dscts} ? $arg->{dscts} : '') .
1362 UCP_DELIMITER .
1363 (exists $arg->{mt} ? $arg->{mt} : '') .
1364 UCP_DELIMITER .
1365 (exists $arg->{nb} ? $arg->{nb} : '') .
1366 UCP_DELIMITER .
1367 $text .
1368 UCP_DELIMITER .
1369 (exists $arg->{mms} ? $arg->{mms} : '') .
1370 UCP_DELIMITER .
1371 (exists $arg->{pr} ? $arg->{pr} : '') .
1372 UCP_DELIMITER .
1373 (exists $arg->{dcs} ? $arg->{dcs} : '') .
1374 UCP_DELIMITER .
1375 (exists $arg->{mcls} ? $arg->{mcls} : '') .
1376 UCP_DELIMITER .
1377 (exists $arg->{rpi} ? $arg->{rpi} : '') .
1378 UCP_DELIMITER .
1379 (exists $arg->{cpg} ? $arg->{cpg} : '') .
1380 UCP_DELIMITER .
1381 (exists $arg->{rply} ? $arg->{rply} : '') .
1382 UCP_DELIMITER .
1383 (exists $arg->{otoa} ? $arg->{otoa} : '') .
1384 UCP_DELIMITER .
1385 (exists $arg->{hplmn} ? $arg->{hplmn} : '') .
1386 UCP_DELIMITER .
1387 (exists $arg->{xser} ? $arg->{xser} : '') .
1388 UCP_DELIMITER .
1389 (exists $arg->{res4} ? $arg->{res4} : '') .
1390 UCP_DELIMITER .
1391 1 ▶ (exists $arg->{res5} ? $arg->{res5} : '')
Branch: 31 branches
BranchTrueFalseTotal
exists $arg->{'adc'} ? : 1 0 1
exists $arg->{'ac'} ? : 0 1 1
exists $arg->{'nrq'} ? : 0 1 1
exists $arg->{'nadc'} ? : 0 1 1
exists $arg->{'nt'} ? : 0 1 1
exists $arg->{'npid'} ? : 0 1 1
exists $arg->{'lrq'} ? : 0 1 1
exists $arg->{'lrad'} ? : 0 1 1
exists $arg->{'lpid'} ? : 0 1 1
exists $arg->{'dd'} ? : 0 1 1
exists $arg->{'ddt'} ? : 0 1 1
exists $arg->{'vp'} ? : 0 1 1
exists $arg->{'rpid'} ? : 0 1 1
exists $arg->{'scts'} ? : 0 1 1
exists $arg->{'dst'} ? : 0 1 1
exists $arg->{'rsn'} ? : 0 1 1
exists $arg->{'dscts'} ? : 0 1 1
exists $arg->{'mt'} ? : 1 0 1
exists $arg->{'nb'} ? : 0 1 1
exists $arg->{'mms'} ? : 0 1 1
exists $arg->{'pr'} ? : 0 1 1
exists $arg->{'dcs'} ? : 0 1 1
exists $arg->{'mcls'} ? : 1 0 1
exists $arg->{'rpi'} ? : 0 1 1
exists $arg->{'cpg'} ? : 0 1 1
exists $arg->{'rply'} ? : 0 1 1
exists $arg->{'otoa'} ? : 1 0 1
exists $arg->{'hplmn'} ? : 0 1 1
exists $arg->{'xser'} ? : 0 1 1
exists $arg->{'res4'} ? : 0 1 1
exists $arg->{'res5'} ? : 0 1 1
1392 ;
1393
1394 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
1395 UCP_DELIMITER .
1396 1 $self->{OBJ_EMI_COMMON}->data_len($string) .
1397 UCP_DELIMITER.
1398 'O'.
1399 UCP_DELIMITER.
1400 $op_type;
1401
1402 $message_string = $header.
1403 UCP_DELIMITER .
1404 $string .
1405 UCP_DELIMITER .
1406 1 $self->{OBJ_EMI_COMMON}->checksum($header .
1407 UCP_DELIMITER .
1408 $string .
1409 UCP_DELIMITER);
1410  
1411 ▶ } elsif (exists($arg->{result}) and $arg->{result} == 1) {
Condition0%0/3
exists $arg->{"result"} and $arg->{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg->{"result"} and $arg->{"result"} == 1
exists $arg->{"result"} $arg->{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg->{"result"}B= $arg->{"result"} == 1
ABresult
0X0
100
111
1412
1413 0 ▶ if (exists $arg->{ack} and $arg->{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg->{'ack'} and $arg->{'ack'} ne '') { } 0 0 0
elsif (exists $arg->{'nack'} and $arg->{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg->{"ack"} and $arg->{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg->{"ack"} and $arg->{"ack"} ne ""
exists $arg->{"ack"} $arg->{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg->{"ack"}B= $arg->{"ack"} ne ""
ABresult
0X0
100
111
1414
1415 my $string =
1416 $arg->{ack} .
1417 UCP_DELIMITER .
1418 (exists $arg->{mvp} ? $arg->{mvp} : '') .
1419 UCP_DELIMITER .
1420 0 ▶ (exists $arg->{sm} ? $arg->{sm} : '') ;
Branch: 2 branches
BranchTrueFalseTotal
exists $arg->{'mvp'} ? : 0 0 0
exists $arg->{'sm'} ? : 0 0 0
1421  
1422 my $header = sprintf("%02d",$arg->{trn}) .
1423 UCP_DELIMITER .
1424 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1425 UCP_DELIMITER.
1426 'R'.
1427 UCP_DELIMITER.
1428 $op_type;
1429  
1430 $message_string = $header.
1431 UCP_DELIMITER .
1432 $string .
1433 UCP_DELIMITER .
1434 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1435 UCP_DELIMITER .
1436 $string .
1437 UCP_DELIMITER);
1438  
1439 ▶ } elsif (exists $arg->{nack} and $arg->{nack} ne '') {
Condition0%0/3
exists $arg->{"nack"} and $arg->{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg->{"nack"} and $arg->{"nack"} ne ""
exists $arg->{"nack"} $arg->{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg->{"nack"}B= $arg->{"nack"} ne ""
ABresult
0X0
100
111
1440
1441 my $string =
1442 $arg->{nack} .
1443 UCP_DELIMITER .
1444 (exists $arg->{ec} ? $arg->{ec} : '') .
1445 UCP_DELIMITER .
1446 0 ▶ (exists $arg->{sm} ? $arg->{sm} : '') ;
Branch: 2 branches
BranchTrueFalseTotal
exists $arg->{'ec'} ? : 0 0 0
exists $arg->{'sm'} ? : 0 0 0
1447  
1448 my $header = sprintf("%02d",$arg->{trn}) .
1449 UCP_DELIMITER .
1450 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1451 UCP_DELIMITER.
1452 'R'.
1453 UCP_DELIMITER.
1454 $op_type;
1455  
1456 $message_string = $header.
1457 UCP_DELIMITER .
1458 $string .
1459 UCP_DELIMITER .
1460 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1461 UCP_DELIMITER .
1462 $string .
1463 UCP_DELIMITER);
1464 }
1465 }
1466
1467 1 return $message_string;
1468 }
1469  
1470 #submit
1471 0 ▶sub parse_51 {
Subroutine parse_51: not called CC=1 SCAR=6.9
Pod undocumented
1472 0 my ($self, $response)=@_;
1473 0 return $self->_parse_5x($response);
1474 }
1475  
1476 #OP 52 delivery short message
1477 0 ▶sub parse_52 {
Subroutine parse_52: not called CC=1 SCAR=6.9
Pod undocumented
1478 0 my ($self, $response)=@_;
1479 0 return $self->_parse_5x($response);
1480 }
1481  
1482 0 ▶sub parse_53 {
Subroutine parse_53: not called CC=1 SCAR=6.9
Pod undocumented
1483 0 my ($self, $response)=@_;
1484 0 return $self->_parse_5x($response);
1485 }
1486  
1487 0 ▶sub parse_54 {
Subroutine parse_54: not called CC=1 SCAR=6.9
Pod undocumented
1488 0 my ($self, $response)=@_;
1489 0 return $self->_parse_5x($response);
1490 }
1491  
1492 0 ▶sub parse_55 {
Subroutine parse_55: not called CC=1 SCAR=6.9
Pod undocumented
1493 0 my ($self, $response)=@_;
1494 0 return $self->_parse_5x($response);
1495 }
1496  
1497 0 ▶sub parse_56 {
Subroutine parse_56: not called CC=1 SCAR=6.9
Pod undocumented
1498 0 my ($self, $response)=@_;
1499 0 return $self->_parse_5x($response);
1500 }
1501  
1502 0 ▶sub parse_57 {
Subroutine parse_57: not called CC=1 SCAR=6.9
Pod undocumented
1503 0 my ($self, $response)=@_;
1504 0 return $self->_parse_5x($response);
1505 }
1506  
1507 0 ▶sub parse_58 {
Subroutine parse_58: not called CC=1 SCAR=6.9
Pod undocumented
1508 0 my ($self, $response)=@_;
1509 0 return $self->_parse_5x($response);
1510 }
1511  
1512 1 ▶sub make_51 {
Subroutine make_51: called CC=1 SCAR=0.0
Pod undocumented
1513 1 my ($self) = shift;
1514 1 my %arg = @_;
1515 1 return $self->_make_5x(\%arg,'51');
1516 }
1517  
1518 0 ▶sub make_52 {
Subroutine make_52: not called CC=1 SCAR=6.9
Pod undocumented
1519 0 my ($self) = shift;
1520 0 my %arg = @_;
1521 0 return $self->_make_5x(\%arg,'52');
1522 }
1523  
1524 0 ▶sub make_53 {
Subroutine make_53: not called CC=1 SCAR=6.9
Pod undocumented
1525 0 my ($self) = shift;
1526 0 my %arg = @_;
1527 0 return $self->_make_5x(\%arg,'53');
1528 }
1529  
1530 0 ▶sub make_54 {
Subroutine make_54: not called CC=1 SCAR=6.9
Pod undocumented
1531 0 my ($self) = shift;
1532 0 my %arg = @_;
1533 0 return $self->_make_5x(\%arg,'54');
1534 }
1535  
1536 0 ▶sub make_55 {
Subroutine make_55: not called CC=1 SCAR=6.9
Pod undocumented
1537 0 my ($self) = shift;
1538 0 my %arg = @_;
1539 0 return $self->_make_5x(\%arg,'55');
1540 }
1541  
1542 0 ▶sub make_56 {
Subroutine make_56: not called CC=1 SCAR=6.9
Pod undocumented
1543 0 my ($self) = shift;
1544 0 my %arg = @_;
1545 0 return $self->_make_5x(\%arg,'56');
1546 }
1547  
1548 0 ▶sub make_57 {
Subroutine make_57: not called CC=1 SCAR=6.9
Pod undocumented
1549 0 my ($self) = shift;
1550 0 my %arg = @_;
1551 0 return $self->_make_5x(\%arg,'57');
1552 }
1553  
1554 0 ▶sub make_58 {
Subroutine make_58: not called CC=1 SCAR=6.9
Pod undocumented
1555 0 my ($self) = shift;
1556 0 my %arg = @_;
1557 0 return $self->_make_5x(\%arg,'58');
1558 }
1559  
1560  
1561 #OP 60 abstract
1562 0 ▶sub parse_60 {
Subroutine parse_60: not called CC=3 SCAR=24.8
Pod undocumented
1563 0 my ($self, $response)=@_;
1564 0 my %mess;
1565  
1566 0 my $resp_tmp = $response;
1567 0 $resp_tmp =~ s/..$//;
1568 0 $mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp);
1569  
1570 0 my (@ucp) = split(UCP_DELIMITER,$response);
1571 #header...
1572 0 $mess{trn} = $ucp[0];
1573 0 $mess{len} = $ucp[1];
1574 0 $mess{type} = $ucp[2];
1575 0 $mess{ot} = $ucp[3];
1576
1577 0 ▶ if ($mess{type} eq "O") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess{'type'} eq 'O') { } 0 0 0
1578 0 $mess{oadc} = $ucp[4];
1579 0 $mess{oton} = $ucp[5];
1580 0 $mess{onpi} = $ucp[6];
1581 0 $mess{styp} = $ucp[7];
1582 0 $mess{pwd} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[8]);
1583 0 $mess{npwd} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[9]);
1584 0 $mess{vers} = $ucp[10];
1585 0 $mess{ladc} = $ucp[11];
1586 0 $mess{lton} = $ucp[12];
1587 0 $mess{lnpi} = $ucp[13];
1588 0 $mess{opid} = $ucp[14];
1589 0 $mess{res1} = $ucp[15];
1590 0 $mess{checksum} = $ucp[16];
1591 } else {
1592 0 ▶ if ($ucp[4] eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucp[4] eq 'A') { } 0 0 0
1593 0 $mess{ack} = $ucp[4];
1594 0 $mess{sm} = $ucp[5];
1595 0 $mess{checksum} = $ucp[6];
1596 } else {
1597 0 $mess{nack} = $ucp[4];
1598 0 $mess{ec} = $ucp[5];
1599 0 $mess{sm} = $ucp[6];
1600 0 $mess{checksum} = $ucp[7];
1601 }
1602 }
1603
1604 0 return \%mess;
1605 }
1606  
1607 0 ▶sub parse_61 {
Subroutine parse_61: not called CC=1 SCAR=6.9
Pod undocumented
1608 0 my ($self, $response)=@_;
1609 0 return $self->parse_60($response);
1610 }
1611  
1612  
1613 0 ▶sub make_60 {
Subroutine make_60: not called CC=24 SCAR=64.0
Pod undocumented
1614 0 my ($self) = shift;
1615 0 my %arg = @_;
1616  
1617 0 my $message_string = undef;
1618  
1619 0 ▶ if (exists $arg{operation} and $arg{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'operation'} and $arg{'operation'} == 1) { } 0 0 0
elsif (exists $arg{'result'} and $arg{'result'} == 1) { } 0 0 0
Condition0%0/3
exists $arg{"operation"} and $arg{"operation"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"operation"} and $arg{"operation"} == 1
exists $arg{"operation"} $arg{"operation"} == 1
Truth table0%0/3
A and B
A= exists $arg{"operation"}B= $arg{"operation"} == 1
ABresult
0X0
100
111
1620  
1621 my $string =
1622 (exists $arg{oadc} ? $arg{oadc} : '') .
1623 UCP_DELIMITER .
1624 (exists $arg{oton} ? $arg{oton} : '') .
1625 UCP_DELIMITER .
1626 (exists $arg{onpi} ? $arg{onpi} : '') .
1627 UCP_DELIMITER .
1628 (exists $arg{styp} ? $arg{styp} : '') .
1629 UCP_DELIMITER .
1630 (exists $arg{pwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{pwd}) : '') .
1631 UCP_DELIMITER .
1632 (exists $arg{npwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{npwd}) : '') .
1633 UCP_DELIMITER .
1634 (exists $arg{vers} ? $arg{vers} : '') .
1635 UCP_DELIMITER .
1636 (exists $arg{ladc} ? $arg{ladc} : '') .
1637 UCP_DELIMITER .
1638 (exists $arg{lton} ? $arg{lton} : '') .
1639 UCP_DELIMITER .
1640 (exists $arg{lnpi} ? $arg{lnpi} : '') .
1641 UCP_DELIMITER .
1642 (exists $arg{opid} ? $arg{opid} : '') .
1643 UCP_DELIMITER .
1644 0 ▶ (exists $arg{res1} ? $arg{res1} : '') ;
Branch: 12 branches
BranchTrueFalseTotal
exists $arg{'oadc'} ? : 0 0 0
exists $arg{'oton'} ? : 0 0 0
exists $arg{'onpi'} ? : 0 0 0
exists $arg{'styp'} ? : 0 0 0
exists $arg{'pwd'} ? : 0 0 0
exists $arg{'npwd'} ? : 0 0 0
exists $arg{'vers'} ? : 0 0 0
exists $arg{'ladc'} ? : 0 0 0
exists $arg{'lton'} ? : 0 0 0
exists $arg{'lnpi'} ? : 0 0 0
exists $arg{'opid'} ? : 0 0 0
exists $arg{'res1'} ? : 0 0 0
1645
1646 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
1647 UCP_DELIMITER .
1648 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1649 UCP_DELIMITER.
1650 'O'.
1651 UCP_DELIMITER.
1652 '60';
1653
1654 $message_string = $header.
1655 UCP_DELIMITER .
1656 $string .
1657 UCP_DELIMITER .
1658 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1659 UCP_DELIMITER .
1660 $string .
1661 UCP_DELIMITER);
1662  
1663 ▶ } elsif (exists($arg{result}) and $arg{result} == 1) {
Condition0%0/3
exists $arg{"result"} and $arg{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"result"} and $arg{"result"} == 1
exists $arg{"result"} $arg{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg{"result"}B= $arg{"result"} == 1
ABresult
0X0
100
111
1664  
1665 0 ▶ if (exists $arg{ack} and $arg{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'ack'} and $arg{'ack'} ne '') { } 0 0 0
elsif (exists $arg{'nack'} and $arg{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg{"ack"} and $arg{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"ack"} and $arg{"ack"} ne ""
exists $arg{"ack"} $arg{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"ack"}B= $arg{"ack"} ne ""
ABresult
0X0
100
111
1666
1667 my $string =
1668 $arg{ack} .
1669 UCP_DELIMITER .
1670 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'sm'} ? : 0 0 0
1671  
1672 my $header = sprintf("%02d",$arg{trn}) .
1673 UCP_DELIMITER .
1674 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1675 UCP_DELIMITER.
1676 'R'.
1677 UCP_DELIMITER.
1678 '60';
1679  
1680 $message_string = $header.
1681 UCP_DELIMITER .
1682 $string .
1683 UCP_DELIMITER .
1684 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1685 UCP_DELIMITER .
1686 $string .
1687 UCP_DELIMITER);
1688
1689 ▶ } elsif (exists $arg{nack} and $arg{nack} ne '') {
Condition0%0/3
exists $arg{"nack"} and $arg{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nack"} and $arg{"nack"} ne ""
exists $arg{"nack"} $arg{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"nack"}B= $arg{"nack"} ne ""
ABresult
0X0
100
111
1690
1691 my $string =
1692 $arg{nack} .
1693 UCP_DELIMITER .
1694 (exists $arg{ec} ? $arg{ec} : '') .
1695 UCP_DELIMITER .
1696 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'ec'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
1697  
1698 my $header = sprintf("%02d",$arg{trn}) .
1699 UCP_DELIMITER .
1700 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1701 UCP_DELIMITER.
1702 'R'.
1703 UCP_DELIMITER.
1704 '60';
1705  
1706 $message_string = $header.
1707 UCP_DELIMITER .
1708 $string .
1709 UCP_DELIMITER .
1710 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1711 UCP_DELIMITER .
1712 $string .
1713 UCP_DELIMITER);
1714 }
1715 }
1716
1717 0 return $message_string;
1718 }
1719  
1720  
1721 0 ▶sub make_61 {
Subroutine make_61: not called CC=25 SCAR=64.8
Pod undocumented
1722 0 my ($self) = shift;
1723 0 my %arg = @_;
1724  
1725 0 my $message_string = undef;
1726  
1727 0 ▶ if (exists $arg{operation} and $arg{operation} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'operation'} and $arg{'operation'} == 1) { } 0 0 0
elsif (exists $arg{'result'} and $arg{'result'} == 1) { } 0 0 0
Condition0%0/3
exists $arg{"operation"} and $arg{"operation"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"operation"} and $arg{"operation"} == 1
exists $arg{"operation"} $arg{"operation"} == 1
Truth table0%0/3
A and B
A= exists $arg{"operation"}B= $arg{"operation"} == 1
ABresult
0X0
100
111
1728  
1729 my $string =
1730 (exists $arg{oadc} ? $arg{oadc} : '') .
1731 UCP_DELIMITER .
1732 (exists $arg{oton} ? $arg{oton} : '') .
1733 UCP_DELIMITER .
1734 (exists $arg{onpi} ? $arg{onpi} : '') .
1735 UCP_DELIMITER .
1736 (exists $arg{styp} ? $arg{styp} : '') .
1737 UCP_DELIMITER .
1738 (exists $arg{pwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{pwd}) : '') .
1739 UCP_DELIMITER .
1740 (exists $arg{npwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{npwd}) : '') .
1741 UCP_DELIMITER .
1742 (exists $arg{vers} ? $arg{vers} : '') .
1743 UCP_DELIMITER .
1744 (exists $arg{ladc} ? $arg{ladc} : '') .
1745 UCP_DELIMITER .
1746 (exists $arg{lton} ? $arg{lton} : '') .
1747 UCP_DELIMITER .
1748 (exists $arg{lnpi} ? $arg{lnpi} : '') .
1749 UCP_DELIMITER .
1750 (exists $arg{opid} ? $arg{opid} : '') .
1751 UCP_DELIMITER .
1752 (exists $arg{res1} ? $arg{res1} : '') .
1753 UCP_DELIMITER .
1754 0 ▶ (exists $arg{res2} ? $arg{res2} : '') ;
Branch: 13 branches
BranchTrueFalseTotal
exists $arg{'oadc'} ? : 0 0 0
exists $arg{'oton'} ? : 0 0 0
exists $arg{'onpi'} ? : 0 0 0
exists $arg{'styp'} ? : 0 0 0
exists $arg{'pwd'} ? : 0 0 0
exists $arg{'npwd'} ? : 0 0 0
exists $arg{'vers'} ? : 0 0 0
exists $arg{'ladc'} ? : 0 0 0
exists $arg{'lton'} ? : 0 0 0
exists $arg{'lnpi'} ? : 0 0 0
exists $arg{'opid'} ? : 0 0 0
exists $arg{'res1'} ? : 0 0 0
exists $arg{'res2'} ? : 0 0 0
1755
1756 my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) .
1757 UCP_DELIMITER .
1758 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1759 UCP_DELIMITER.
1760 'O'.
1761 UCP_DELIMITER.
1762 '61';
1763
1764 $message_string = $header.
1765 UCP_DELIMITER .
1766 $string .
1767 UCP_DELIMITER .
1768 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1769 UCP_DELIMITER .
1770 $string .
1771 UCP_DELIMITER);
1772  
1773 ▶ } elsif (exists($arg{result}) and $arg{result} == 1) {
Condition0%0/3
exists $arg{"result"} and $arg{"result"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"result"} and $arg{"result"} == 1
exists $arg{"result"} $arg{"result"} == 1
Truth table0%0/3
A and B
A= exists $arg{"result"}B= $arg{"result"} == 1
ABresult
0X0
100
111
1774  
1775 0 ▶ if (exists $arg{ack} and $arg{ack} ne '') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $arg{'ack'} and $arg{'ack'} ne '') { } 0 0 0
elsif (exists $arg{'nack'} and $arg{'nack'} ne '') { } 0 0 0
Condition0%0/3
exists $arg{"ack"} and $arg{"ack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"ack"} and $arg{"ack"} ne ""
exists $arg{"ack"} $arg{"ack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"ack"}B= $arg{"ack"} ne ""
ABresult
0X0
100
111
1776
1777 my $string =
1778 $arg{ack} .
1779 UCP_DELIMITER .
1780 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'sm'} ? : 0 0 0
1781  
1782 my $header = sprintf("%02d",$arg{trn}) .
1783 UCP_DELIMITER .
1784 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1785 UCP_DELIMITER.
1786 'R'.
1787 UCP_DELIMITER.
1788 '61';
1789  
1790 $message_string = $header.
1791 UCP_DELIMITER .
1792 $string .
1793 UCP_DELIMITER .
1794 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1795 UCP_DELIMITER .
1796 $string .
1797 UCP_DELIMITER);
1798
1799 ▶ } elsif (exists $arg{nack} and $arg{nack} ne '') {
Condition0%0/3
exists $arg{"nack"} and $arg{"nack"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg{"nack"} and $arg{"nack"} ne ""
exists $arg{"nack"} $arg{"nack"} ne ""
Truth table0%0/3
A and B
A= exists $arg{"nack"}B= $arg{"nack"} ne ""
ABresult
0X0
100
111
1800
1801 my $string =
1802 $arg{nack} .
1803 UCP_DELIMITER .
1804 (exists $arg{ec} ? $arg{ec} : '') .
1805 UCP_DELIMITER .
1806 0 ▶ (exists $arg{sm} ? $arg{sm} : '') ;
Branch: 2 branches
BranchTrueFalseTotal
exists $arg{'ec'} ? : 0 0 0
exists $arg{'sm'} ? : 0 0 0
1807  
1808 my $header = sprintf("%02d",$arg{trn}) .
1809 UCP_DELIMITER .
1810 0 $self->{OBJ_EMI_COMMON}->data_len($string) .
1811 UCP_DELIMITER.
1812 'R'.
1813 UCP_DELIMITER.
1814 '61';
1815  
1816 $message_string = $header.
1817 UCP_DELIMITER .
1818 $string .
1819 UCP_DELIMITER .
1820 0 $self->{OBJ_EMI_COMMON}->checksum($header .
1821 UCP_DELIMITER .
1822 $string .
1823 UCP_DELIMITER);
1824 }
1825 }
1826
1827 0 return $message_string;
1828 }
1829  
1830 #it doesn't get response!
1831 #param : host, port, listen
1832 #param : output, action, sending
1833 #param : reading_mode (0 = line feed at the end, 1 = reading defined message length - default 1Kb)
1834 #param : max_len (for reading_mode = 1)
1835 ##################################
1836 0 ▶sub create_fake_smsc {
Subroutine create_fake_smsc: not called CC=33 SCAR=70.2
Pod undocumented
1837 0 my $self = shift;
1838 0 my %opt = @_;
1839
1840 0 my $remote_socket = undef;
1841
1842 my $main_socket = new IO::Socket::INET (LocalHost => exists $opt{host} && $opt{host} ne '' ? $opt{host} : '127.0.0.1',
1843 LocalPort => exists $opt{port} && $opt{port} ne '' ? $opt{port} : 6666,
1844 0 ▶ Listen => exists $opt{listen} ? $opt{listen} : 5,
Branch: 3 branches
BranchTrueFalseTotal
exists $opt{'host'} && $opt{'host'} ne '' ? : 0 0 0
exists $opt{'port'} && $opt{'port'} ne '' ? : 0 0 0
exists $opt{'listen'} ? : 0 0 0
Condition0%0/6
exists $opt{"host"} and $opt{"host"} ne ""
!ll&&!rl&&r
000
exists $opt{"port"} and $opt{"port"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opt{"host"} and $opt{"host"} ne ""
exists $opt{"host"} $opt{"host"} ne ""
MC/DC0%0/2
exists $opt{"port"} and $opt{"port"} ne ""
exists $opt{"port"} $opt{"port"} ne ""
Truth table0%0/3
A and B
A= exists $opt{"host"}B= $opt{"host"} ne ""
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= exists $opt{"port"}B= $opt{"port"} ne ""
ABresult
0X0
100
111
1845 Proto => 'tcp',
1846 Reuse => 1,
1847 );
1848 0 ▶ croak "Fake SMSC could not be created, [$!]\n" unless ($main_socket);
Branch: 1 branch
BranchTrueFalseTotal
unless $main_socket 0 0 0
1849
1850  
1851 0 ▶ my $debug = (exists $opt{output} and $opt{output} == 1) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $opt{'output'} && $opt{'output'} == 1 ? : 0 0 0
Condition0%0/3
exists $opt{"output"} and $opt{"output"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opt{"output"} and $opt{"output"} == 1
exists $opt{"output"} $opt{"output"} == 1
Truth table0%0/3
A and B
A= exists $opt{"output"}B= $opt{"output"} == 1
ABresult
0X0
100
111
1852  
1853 0 my $reading_mode = 0;
1854 0 ▶ if (exists $opt{reading_mode}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{"reading_mode"}) 0 0 0
1855 0 ▶ if ($opt{reading_mode} != 0 && $opt{reading_mode} != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{'reading_mode'} != 0 and $opt{'reading_mode'} != 1) { } 0 0 0
Condition0%0/3
$opt{"reading_mode"} != 0 and $opt{"reading_mode"} != 1
!ll&&!rl&&r
000
MC/DC0%0/2
$opt{"reading_mode"} != 0 and $opt{"reading_mode"} != 1
$opt{"reading_mode"} != 0 $opt{"reading_mode"} != 1
Truth table0%0/3
A and B
A= $opt{"reading_mode"} != 0B= $opt{"reading_mode"} != 1
ABresult
0X0
100
111
1856 0 $reading_mode = 0;
1857 } else {
1858 0 $reading_mode = $opt{reading_mode};
1859 }
1860 }
1861
1862 0 ▶ my $max_len = (exists $opt{max_len} and $opt{max_len} >= 1) ? $opt{max_len} : 1024;
Branch: 1 branch
BranchTrueFalseTotal
exists $opt{'max_len'} && $opt{'max_len'} >= 1 ? : 0 0 0
Condition0%0/3
exists $opt{"max_len"} and $opt{"max_len"} >= 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opt{"max_len"} and $opt{"max_len"} >= 1
exists $opt{"max_len"} $opt{"max_len"} >= 1
Truth table0%0/3
A and B
A= exists $opt{"max_len"}B= $opt{"max_len"} >= 1
ABresult
0X0
100
111
1863
1864 0 my $readable_handles = new IO::Select();
1865 0 $readable_handles->add($main_socket);
1866  
1867 0 my ($sock, $new_sock);
1868
1869 0 while (1) {
1870 0 my ($new_readable) = IO::Select->select($readable_handles, undef, undef, undef);
1871 0 foreach $sock (@$new_readable) {
1872 0 ▶ if ($sock == $main_socket) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sock == $main_socket) { } 0 0 0
1873 0 $new_sock = $sock->accept();
1874 0 $readable_handles->add($new_sock);
1875 } else {
1876  
1877 0 ▶ print "[*] Reading on socket [$sock]\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1878 0 my $message = 0;
1879  
1880 0 ▶ $message = <$sock> if (!$reading_mode);
Branch: 1 branch
BranchTrueFalseTotal
unless $reading_mode 0 0 0
1881 0 ▶ $sock->recv($message, $max_len) if ($reading_mode == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $reading_mode == 1 0 0 0
1882
1883 0 ▶ if ($message) {
Branch: 1 branch
BranchTrueFalseTotal
if ($message) { } 0 0 0
1884 0 $message =~ s/[\n\r]//g;
1885 0 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 0 0
1886 0 print "\n\n[*] UCP string -\n";
1887 0 print "-"x30;
1888 0 print "\n" . $message . "\n";
1889 0 print "-"x30;
1890 0 print "\n";
1891 }
1892
1893 0 ▶ if (exists $opt{action} and ref($opt{action}) eq "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{'action'} and ref $opt{'action'} eq 'CODE') { } 0 0 0
Condition0%0/3
exists $opt{"action"} and ref $opt{"action"} eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opt{"action"} and ref $opt{"action"} eq "CODE"
exists $opt{"action"} ref $opt{"action"} eq "CODE"
Truth table0%0/3
A and B
A= exists $opt{"action"}B= ref $opt{"action"} eq "CODE"
ABresult
0X0
100
111
1894 0 my $resp_be = $opt{action}($message);
1895 0 ▶ print $sock $resp_be if (defined($resp_be) && ($resp_be ne ''));
Branch: 1 branch
BranchTrueFalseTotal
if defined $resp_be and $resp_be ne "" 0 0 0
Condition0%0/3
defined $resp_be and $resp_be ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $resp_be and $resp_be ne ""
defined $resp_be $resp_be ne ""
Truth table0%0/3
A and B
A= defined $resp_beB= $resp_be ne ""
ABresult
0X0
100
111
1896  
1897 0 ▶ if (exists $opt{sending} and ref($opt{sending}) eq "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{"sending"} and ref $opt{"sending"} eq "CODE") 0 0 0
Condition0%0/3
exists $opt{"sending"} and ref $opt{"sending"} eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opt{"sending"} and ref $opt{"sending"} eq "CODE"
exists $opt{"sending"} ref $opt{"sending"} eq "CODE"
Truth table0%0/3
A and B
A= exists $opt{"sending"}B= ref $opt{"sending"} eq "CODE"
ABresult
0X0
100
111
1898 0 my $next_ucp_message = $opt{sending}();
1899 0 ▶ print $sock $next_ucp_message if (defined($next_ucp_message) && ($next_ucp_message ne ''));
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_ucp_message and $next_ucp_message ne "" 0 0 0
Condition0%0/3
defined $next_ucp_message and $next_ucp_message ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $next_ucp_message and $next_ucp_message ne ""
defined $next_ucp_message $next_ucp_message ne ""
Truth table0%0/3
A and B
A= defined $next_ucp_messageB= $next_ucp_message ne ""
ABresult
0X0
100
111
1900 }
1901  
1902 } else {
1903 0 my $response = $self->parse_message($message);
1904 0 ▶ if (ref($response) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $response eq 'HASH') { } 0 0 0
1905 0 foreach my $k (keys %{$response}) {
1906 0 ▶ print "\nP.Name: [$k] - Value:\t$response->{$k}" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1907 }
1908 } else {
1909 0 print "Error while parsing message\n";
1910 }
1911 }
1912 } else {
1913
1914 0 ▶ print "[*] Closing socket [$sock]\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1915 0 $readable_handles->remove($sock);
1916 0 close($sock);
1917
1918 }
1919 }
1920 }
1921 }
1922
1923 0 return;
1924 }
1925  
1926 0 ▶sub transmit_msg {
Subroutine transmit_msg: not called CC=25 SCAR=64.8
Pod documented
1927 0 my($self, $message_string, $timeout, $need_resp) = @_;
1928  
1929 0 my($rd,$buffer,$response,$acknack,$errcode,$errtxt,$ack);
1930  
1931 0 ▶ defined($timeout) || do{ $timeout = 0 };
Branch: 1 branch
BranchTrueFalseTotal
defined $timeout or do { $timeout = 0 } 0 0 0
1932  
1933 0 ▶ if (!defined($self->{SOCK})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"SOCK"}) 0 0 0
1934 0 die "Unable to send message : smsc socket is not initialized, maybe u are using it in FAKE mode... ";
1935 }
1936 0 my $enclosed = STX . $message_string . ETX;
1937  
1938 0 ▶ print {$self->{SOCK}} $enclosed || do {
Condition0%0/3
$enclosed || do { $errtxt = 'Failed to print to SMSC socket. Remote end closed?'; $self->{'WARN'} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef }
l!l&&r!l&&!r
000
MC/DC0%0/2
$enclosed || do { $errtxt = 'Failed to print to SMSC socket. Remote end closed?'; $self->{'WARN'} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef }
$enclosed do { $errtxt = 'Failed to print to SMSC socket. Remote end closed?'; $self->{'WARN'} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef }
Truth table0%0/3
A || B
A= $enclosedB= do { $errtxt = 'Failed to print to SMSC socket. Remote end closed?'; $self->{'WARN'} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef }
ABresult
1X1
011
000
1939 0 $errtxt = "Failed to print to SMSC socket. Remote end closed?";
1940 0 ▶ $self->{WARN} && warn($errtxt);
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn $errtxt 0 0 0
1941 0 ▶ return(defined(wantarray) ? wantarray?(undef,0,$errtxt) : undef : undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
1942 };
1943
1944 0 $self->{SOCK}->flush();
1945  
1946 0 ▶ if ($need_resp == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($need_resp == 1) { } 0 0 0
1947 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$buffer eq "\3" or do { do { if ($self->{"CAN_ALARM"}) { eval { do { $rd = undef; local(local $SIG{"ALRM"}) = sub { die "alarm\n"; } ; alarm $timeout; $rd = read($self->{"SOCK"}, $buffer, 1); alarm 0 } }; $@ and $@ ne "alarm\n" and die $@; } else { $rd = read($self->{"SOCK"}, $buffer, 1); } ; defined $rd or do { $errtxt = "Failed to read from SMSC socket. Never received ETX. Remote end closed?"; $self->{"WARN"} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef }; $rd or do { $errtxt = "Never received ETX from SMSC. Remote end closed?"; $self->{"WARN"} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef }; $response .= $buffer } } 0 0 0
1948 # If this system implements alarm(), we will do a non-blocking read.
1949 0 ▶ if($self->{CAN_ALARM}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CAN_ALARM'}) { } 0 0 0
1950 0 eval {
1951 0 $rd=undef;
1952 0 ▶ local($SIG{ALRM})=sub{die("alarm\n")}; # NB: \n required
Subroutine __ANON__: not called CC=1 SCAR=6.9
1953 0 alarm($timeout);
1954 0 $rd=read($self->{SOCK},$buffer,1);
1955 0 alarm(0);
1956 };
1957 # Propagate unexpected errors.
1958 0 ▶ $@&&$@ne"alarm\n"&&die($@);
Branch: 1 branch
BranchTrueFalseTotal
$@ and $@ ne "alarm\n" and die $@ 0 0 0
Condition0%0/3
$@ and $@ ne "alarm\n"
!ll&&!rl&&r
000
MC/DC0%0/2
$@ and $@ ne "alarm\n"
$@ $@ ne "alarm\n"
Truth table0%0/3
A and B
A= $@B= $@ ne "alarm\n"
ABresult
0X0
100
111
1959 }
1960 else {
1961 # No alarm() implemented. Must do a (potentially) blocking call to read().
1962 0 $rd=read($self->{SOCK},$buffer,1);
1963 }
1964 0 ▶ defined($rd)||do{ # undef, read error.
Branch: 1 branch
BranchTrueFalseTotal
defined $rd or do { $errtxt = "Failed to read from SMSC socket. Never received ETX. Remote end closed?"; $self->{"WARN"} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef } 0 0 0
1965 0 $errtxt="Failed to read from SMSC socket. Never received ETX. Remote end closed?";
1966 0 ▶ $self->{WARN}&&warn($errtxt);
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn $errtxt 0 0 0
1967 0 ▶ return(defined(wantarray)?wantarray?(undef,0,$errtxt):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
1968 };
1969 0 ▶ $rd||do{ # Zero, end of 'file'.
Branch: 1 branch
BranchTrueFalseTotal
$rd or do { $errtxt = "Never received ETX from SMSC. Remote end closed?"; $self->{"WARN"} and warn $errtxt; return defined wantarray ? wantarray ? (undef, 0, $errtxt) : undef : undef } 0 0 0
1970 0 $errtxt="Never received ETX from SMSC. Remote end closed?";
1971 0 ▶ $self->{WARN}&&warn($errtxt);
Branch: 1 branch
BranchTrueFalseTotal
$self->{"WARN"} and warn $errtxt 0 0 0
1972 0 ▶ return(defined(wantarray)?wantarray?(undef,0,$errtxt):undef:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
1973 };
1974 0 $response.=$buffer;
1975 } until($buffer eq ETX);
1976  
1977 0 (undef,undef,undef,undef,$acknack,$errcode,$errtxt,undef)=split(UCP_DELIMITER, $response);
1978 0 ▶ if($acknack eq ACK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($acknack eq 'A') { } 0 0 0
1979 0 ($ack,$errcode,$errtxt)=(TRUE,0,'');
1980 }
1981 else {
1982 0 $ack = 0;
1983 0 $errtxt =~ s/^\s+//;
1984 0 $errtxt =~ s/\s+$//;
1985 }
1986
1987 0 $errtxt .= "\nSent : " . $message_string . "\nReceive : " . $response . "\n";
1988 0 ▶ defined(wantarray) ? wantarray ? ($ack, $errcode, $errtxt) : $ack : undef;
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
1989
1990 } else {
1991 0 ▶ defined(wantarray) ? wantarray ? (undef, undef, undef) : undef : undef;
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
1992 }
1993  
1994 }
1995  
1996 1 1;
1997  
1998 __END__
↑ Summary