blib/lib/Ivrs.pm

filter: Statementstmt 8.5% 60 / 700 Branchbran 0.4% 2 / 406 Conditioncond 0.0% 0 / 93 MC/DCmcdc 0.0% 0 / 53 Subroutinesub 20.0% 11 / 55 Podpod 0.0% 0 / 48 totaltotal 5.3% 73 / 1355 CC 239 SCAR 53.9
CC
239
Cov
5%
new
870.0
playfile
870.0
databits
156.0
CRAP 220.0
↑ Summary
1 #Perl module to implement a full functional Interactive Voice Response
2 #System using standard voice modem. I have *taken* some codes from
3 #SerialPort.pm for serial port access, with due respect to Bill Birthisel.
4  
5  
6 package SerialJunk;
7 # this is the linux path. Need to determine location on other OSs
8 1 ▶use vars qw($ioctl_ok);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 eval { require 'asm/termios.ph'; };
10 1 ▶if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 1 0 1
11 1 $ioctl_ok = 0;
12 ## print "error message: $@\n"; ## DEBUG ##
13 }
14 else {
15 0 $ioctl_ok = 1;
16 }
17  
18 package Ivrs;
19 1 ▶use POSIX qw(:termios_h);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use vars qw($bitset $bitclear $rtsout $dtrout $getstat $incount $outcount
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 $txdone);
24 1 ▶if ($SerialJunk::ioctl_ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($SerialJunk::ioctl_ok) { } 0 1 1
25 0 $bitset = &SerialJunk::TIOCMBIS;
26 0 $bitclear = &SerialJunk::TIOCMBIC;
27 0 $getstat = &SerialJunk::TIOCMGET;
28 0 $incount = &SerialJunk::TIOCINQ;
29 0 $outcount = &SerialJunk::TIOCOUTQ;
30 0 $txdone = &SerialJunk::TIOCSERGETLSR;
31 0 $rtsout = pack('L', &SerialJunk::TIOCM_RTS);
32 0 $dtrout = pack('L', &SerialJunk::TIOCM_DTR);
33 }
34 else {
35 1 $bitset = 0;
36 1 $bitclear = 0;
37 1 $statget = 0;
38 1 $incount = 0;
39 1 $outcount = 0;
40 1 $txdone = 0;
41 1 $rtsout = pack('L', 0);
42 1 $dtrout = pack('L', 0);
43 }
44  
45  
46 0 ▶sub TIOCM_LE1 {
Subroutine TIOCM_LE1: not called CC=3 SCAR=24.8
Pod undocumented
47 0 ▶ if (defined &SerialJunk::TIOCSER_TEMT) { return &SerialJunk::TIOCSER_TEMT; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined &SerialJunk::TIOCSER_TEMT) 0 0 0
48 0 ▶ if (defined &SerialJunk::TIOCM_LE) { return &SerialJunk::TIOCM_LE; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined &SerialJunk::TIOCM_LE) 0 0 0
49 0 0;
50 }
51  
52 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 1 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 $VERSION = '0.24';
57  
58 1 require Exporter;
59  
60 1 @ISA = qw(Exporter);
61 1 @EXPORT= qw();
62 1 @EXPORT_OK= qw();
63 1 %EXPORT_TAGS = (STAT => [qw( MS_CTS_ON MS_DSR_ON
64 MS_RING_ON MS_RLSD_ON
65 ST_BLOCK ST_INPUT
66 ST_OUTPUT ST_ERROR )],
67  
68 PARAM => [qw( LONGsize SHORTsize OS_Error
69 nocarp yes_true )]);
70  
71 1 Exporter::export_ok_tags('STAT', 'PARAM');
72  
73 1 $EXPORT_TAGS{ALL} = \@EXPORT_OK;
74  
75 # Linux-specific constant for Hardware Handshaking
76 0 ▶sub CRTSCTS { 020000000000 }
Subroutine CRTSCTS: not called CC=1 SCAR=6.9
Pod undocumented
77  
78 # Linux-specific Baud-Rates
79 1 ▶sub B57600 { 0010001 }
Subroutine B57600: called CC=1 SCAR=0.0
Pod undocumented
80 1 ▶sub B115200 { 0010002 }
Subroutine B115200: called CC=1 SCAR=0.0
Pod undocumented
81 1 ▶sub B230400 { 0010003 }
Subroutine B230400: called CC=1 SCAR=0.0
Pod undocumented
82 1 ▶sub B460800 { 0010004 }
Subroutine B460800: called CC=1 SCAR=0.0
Pod undocumented
83  
84 1 my %bauds = (
85 9600 => B9600,
86 19200 => B19200,
87 38400 => B38400,
88 # These are Linux-specific
89 57600 => B57600,
90 115200 => B115200,
91 230400 => B230400,
92 460800 => B460800,
93 );
94  
95  
96 1 my %c_cc_fields = (
97 VEOF => &POSIX::VEOF,
98 VEOL => &POSIX::VEOL,
99 VERASE => &POSIX::VERASE,
100 VINTR => &POSIX::VINTR,
101 VKILL => &POSIX::VKILL,
102 VQUIT => &POSIX::VQUIT,
103 VSUSP => &POSIX::VSUSP,
104 VSTART => &POSIX::VSTART,
105 VSTOP => &POSIX::VSTOP,
106 VMIN => &POSIX::VMIN,
107 VTIME => &POSIX::VTIME,
108 );
109 #Default directories and filenames. You may specify $vdir from your
110 #programme
111 1 my $vdir="sfiles";
112 1 my $logfile="/var/log/Ivrs_Log";
113 1 my $tmpmsg="/tmp/tmpmsg";
114  
115  
116 #These headers are required for recorded files only.
117 #my $rmdhdr="";
118 # For Rockwell chip set modem
119 1 my $rmdhdr="RMD1Rockwell".pack("C20",0,0,0,0,0,0,0,0,0,4,28,32,4,0,0,0,0,0,0,0);
120 # For US Robotics modem
121 #my $rmdhdr="RMD1US Robotics".pack("C17",0,0,0,0,0,0,8,31,64,1,0,0,0,0,0,0,0);
122  
123 1 my $Babble = 1; #Set to 0 if you do not want lots of garbage in Log File.
124 1 my $testactive = 0; # test mode active
125 1 my @Yes_resp = (
126 "YES", "Y",
127 "ON",
128 "TRUE", "T",
129 "1"
130 );
131  
132 1 my @binary_opt = ( 0, 1 );
133 1 my @byte_opt = (0, 255);
134  
135 ## my $null=[];
136 1 my $null=0;
137 1 my $zero=0;
138  
139 0 ▶sub nocarp { return $testactive }
Subroutine nocarp: not called CC=1 SCAR=6.9
Pod undocumented
140  
141 0 ▶sub yes_true {
Subroutine yes_true: not called CC=3 SCAR=24.8
Pod undocumented
142 0 my $choice = uc shift;
143 0 my $ans = 0;
144 0 ▶ foreach (@Yes_resp) { $ans = 1 if ( $choice eq $_ ) }
Branch: 1 branch
BranchTrueFalseTotal
if $choice eq $_ 0 0 0
145 0 return $ans;
146 }
147  
148 0 ▶sub new {
Subroutine new: not called CC=29 SCAR=67.7
Pod undocumented
149 0 my $proto = shift;
150 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
151 0 my $self = {};
152 0 my $ok = 0; # API return value
153  
154 0 my $item = 0;
155 0 $self->{NAME} = shift;
156 0 ▶ open (LOG, ">>$logfile.$self->{NAME}")||die"Log file failed";
Branch: 1 branch
BranchTrueFalseTotal
open LOG, qq[>>$logfile.$self->{"NAME"}] or die "Log file failed" 0 0 0
157 0 print LOG "\n-----------Access Log file for IVRS-----------\n";
158 0 print LOG `date`;
159 0 $self->{NAME}="/dev/".$self->{NAME} ;
160 0 my $tmpdir=shift;
161 0 ▶ $vdir=$tmpdir if $tmpdir ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $tmpdir ne "" 0 0 0
162 0 my $quiet = shift;
163 0 ▶ unless ($quiet or ($bitset && $bitclear && $rtsout && $dtrout) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($quiet or $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout and $Ivrs::dtrout) 0 0 0
Condition0%0/12
$quiet or $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout and $Ivrs::dtrout
l!l&&r!l&&!r
000
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout and $Ivrs::dtrout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear
!ll&&!rl&&r
000
MC/DC0%0/5
$quiet or $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout and $Ivrs::dtrout
$quiet $Ivrs::bitset $Ivrs::bitclear $Ivrs::rtsout $Ivrs::dtrout
Truth table0%0/6
A or B and C and D and E
A= $quietB= $Ivrs::bitsetC= $Ivrs::bitclearD= $Ivrs::rtsoutE= $Ivrs::dtrout
ABCDEresult
1XXXX1
011111
00XXX0
010XX0
0110X0
011100
164 0 ▶ nocarp or warn "disabling ioctl methods - constants not found\n";
Branch: 1 branch
BranchTrueFalseTotal
nocarp() or warn "disabling ioctl methods - constants not found\n" 0 0 0
165 }
166  
167 0 my $lockfile = shift;
168 0 ▶ if ($lockfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lockfile) { } 0 0 0
169 0 $self->{LOCK} = $lockfile;
170 my $lockf = POSIX::open($self->{LOCK},
171 0 &POSIX::O_WRONLY |
172 &POSIX::O_CREAT |
173 &POSIX::O_NOCTTY |
174 &POSIX::O_EXCL);
175 0 ▶ unless (defined $lockf) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $lockf) 0 0 0
176 0 ▶ unless ($quiet) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($quiet) 0 0 0
177 0 ▶ nocarp or carp "can't open lockfile: $self->{LOCK}\n";
Branch: 1 branch
BranchTrueFalseTotal
nocarp() or carp(qq[can't open lockfile: $self->{"LOCK"}\n]) 0 0 0
178 }
179 0 ▶ return 0 if ($quiet);
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 0 0 0
180 0 return;
181 }
182 0 my $pid = "$$\n";
183 0 $ok = POSIX::write($lockf, $pid, length $pid);
184 0 my $ok2 = POSIX::close($lockf);
185 0 ▶ return unless ($ok && (defined $ok2));
Branch: 1 branch
BranchTrueFalseTotal
unless $ok and defined $ok2 0 0 0
Condition0%0/3
$ok and defined $ok2
!ll&&!rl&&r
000
MC/DC0%0/2
$ok and defined $ok2
$ok defined $ok2
Truth table0%0/3
A and B
A= $okB= defined $ok2
ABresult
0X0
100
111
186 0 sleep 2; # wild guess for Version 0.05
187 }
188 else {
189 0 $self->{LOCK} = "";
190 }
191  
192 $self->{FD}= POSIX::open($self->{NAME},
193 0 &POSIX::O_RDWR |
194 &POSIX::O_NOCTTY |
195 &POSIX::O_NONBLOCK);
196  
197 0 ▶ unless (defined $self->{FD}) { $self->{FD} = -1; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"FD"}) 0 0 0
198 0 ▶ unless ($self->{FD} >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"FD"} >= 1) 0 0 0
199 0 ▶ unless ($quiet) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($quiet) 0 0 0
200 0 ▶ nocarp or carp "can't open device: $self->{NAME}\n";
Branch: 1 branch
BranchTrueFalseTotal
nocarp() or carp(qq[can't open device: $self->{"NAME"}\n]) 0 0 0
201 }
202 0 $self->{FD} = -1;
203 0 ▶ if ($self->{LOCK}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"LOCK"}) 0 0 0
204 0 $ok = unlink $self->{LOCK};
205 0 ▶ unless ($ok or $quiet) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok or $quiet) 0 0 0
Condition0%0/3
$ok or $quiet
l!l&&r!l&&!r
000
MC/DC0%0/2
$ok or $quiet
$ok $quiet
Truth table0%0/3
A or B
A= $okB= $quiet
ABresult
1X1
011
000
206 0 ▶ nocarp or carp "can't remove lockfile: $self->{LOCK}\n";
Branch: 1 branch
BranchTrueFalseTotal
nocarp() or carp(qq[can't remove lockfile: $self->{"LOCK"}\n]) 0 0 0
207 }
208 0 $self->{LOCK} = "";
209 }
210 0 ▶ return 0 if ($quiet);
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 0 0 0
211 0 return;
212 }
213  
214 0 $self->{TERMIOS} = POSIX::Termios->new();
215  
216 # a handle object for ioctls: read-only ok
217 0 $self->{HANDLE} = new_from_fd IO::Handle ($self->{FD}, "r");
218
219 # get the current attributes
220 0 $ok = $self->{TERMIOS}->getattr($self->{FD});
221  
222 0 ▶ unless ( $ok ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 0 0
223 0 carp "can't getattr";
224 0 undef $self;
225 0 return undef;
226 }
227  
228 # save the original values
229 0 $self->{"_CFLAG"} = $self->{TERMIOS}->getcflag();
230 0 $self->{"_IFLAG"} = $self->{TERMIOS}->getiflag();
231 0 $self->{"_ISPEED"} = $self->{TERMIOS}->getispeed();
232 0 $self->{"_LFLAG"} = $self->{TERMIOS}->getlflag();
233 0 $self->{"_OFLAG"} = $self->{TERMIOS}->getoflag();
234 0 $self->{"_OSPEED"} = $self->{TERMIOS}->getospeed();
235  
236 0 foreach $item (keys %c_cc_fields) {
237 0 $self->{"_$item"} = $self->{TERMIOS}->getcc($c_cc_fields{$item});
238 }
239  
240 # copy the original values into "current" values
241 0 foreach $item (keys %c_cc_fields) {
242 0 $self->{"C_$item"} = $self->{"_$item"};
243 }
244  
245 0 $self->{"C_CFLAG"} = $self->{"_CFLAG"};
246 0 $self->{"C_IFLAG"} = $self->{"_IFLAG"};
247 0 $self->{"C_ISPEED"} = $self->{"_ISPEED"};
248 0 $self->{"C_LFLAG"} = $self->{"_LFLAG"};
249 0 $self->{"C_OFLAG"} = $self->{"_OFLAG"};
250 0 $self->{"C_OSPEED"} = $self->{"_OSPEED"};
251  
252 # Finally, default to "raw" mode for this package
253 0 $self->{"C_IFLAG"} &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
254 0 $self->{"C_OFLAG"} &= ~OPOST;
255 0 $self->{"C_LFLAG"} &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
256 0 $self->{"C_CFLAG"} &= ~(CSIZE|PARENB);
257 0 $self->{"C_CFLAG"} |= (CS8|CLOCAL);
258 0 &write_settings($self);
259  
260 0 $self->{ALIAS} = $self->{NAME}; # so "\\.\+++" can be changed
261 0 print LOG "Port $self->{NAME} opened by IVRS\n";
262 0 bless ($self, $class);
263 0 return $self;
264 }
265  
266 0 ▶sub write_settings {
Subroutine write_settings: not called CC=3 SCAR=24.8
Pod undocumented
267 0 my $self = shift;
268 0 my $item;
269  
270 # put current values into Termios structure
271 0 $self->{TERMIOS}->setcflag($self->{"C_CFLAG"});
272 0 $self->{TERMIOS}->setiflag($self->{"C_IFLAG"});
273 0 $self->{TERMIOS}->setispeed($self->{"C_ISPEED"});
274 0 $self->{TERMIOS}->setlflag($self->{"C_LFLAG"});
275 0 $self->{TERMIOS}->setoflag($self->{"C_OFLAG"});
276 0 $self->{TERMIOS}->setospeed($self->{"C_OSPEED"});
277  
278 0 foreach $item (keys %c_cc_fields) {
279 0 $self->{TERMIOS}->setcc($c_cc_fields{$item}, $self->{"C_$item"});
280 }
281  
282 0 $self->{TERMIOS}->setattr($self->{FD}, &POSIX::TCSANOW);
283  
284 0 ▶ if ($Babble) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Babble) 0 0 0
285 # print "writing settings to $self->{ALIAS}\n";
286 }
287 0 1;
288 }
289  
290 0 ▶sub readport {
Subroutine readport: not called CC=8 SCAR=42.8
Pod undocumented
291 0 ▶ return undef unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
292 0 my $self = shift;
293 0 my $wanted = shift;
294 0 my $result = "";
295 0 my $ok = 0;
296 0 ▶ return unless ($wanted > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $wanted > 0 0 0 0
297  
298 0 my $done = 0;
299 0 my $count_in = 0;
300 0 my $string_in = "";
301 0 my $in2 = "";
302 0 my $bufsize = 255; # VMIN max (declared as char)
303  
304 0 ▶ while ($done < $wanted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($done < $wanted) 0 0 0
305 0 my $size = $wanted - $done;
306 0 ▶ if ($size > $bufsize) { $size = $bufsize; }
Branch: 1 branch
BranchTrueFalseTotal
if ($size > $bufsize) 0 0 0
307 0 ($count_in, $string_in) = $self->read_vmin($size);
308 0 ▶ if ($count_in) {
Branch: 2 branches
BranchTrueFalseTotal
if ($count_in) { } 0 0 0
elsif ($done) { } 0 0 0
309 0 $in2 .= $string_in;
310 0 $done += $count_in;
311 }
312 elsif ($done) {
313 0 last;
314 }
315 else {
316 0 ▶ return if (!defined $count_in);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $count_in 0 0 0
317 0 last;
318 }
319 }
320 0 return ($done, $in2);
321 }
322  
323 0 ▶sub read_vmin {
Subroutine read_vmin: not called CC=9 SCAR=45.0
Pod undocumented
324 0 ▶ return undef unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
325 0 my $self = shift;
326 0 my $wanted = shift;
327 0 my $result = "";
328 0 my $ok = 0;
329 0 ▶ return unless ($wanted > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $wanted > 0 0 0 0
330  
331 0 ▶ if ($self->{"C_VMIN"} != $wanted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"C_VMIN"} != $wanted) 0 0 0
332 0 $self->{"C_VMIN"} = $wanted;
333 0 write_settings($self);
334 }
335 0 my $rin = "";
336 0 vec($rin, $self->{FD}, 1) = 1;
337 0 my $ein = $rin;
338 0 my $tin = $self->{RCONST} + ($wanted * $self->{RTOT});
339 0 my $rout;
340 my $wout;
341 0 my $eout;
342 0 my $tout;
343 0 my $ready = select($rout=$rin, $wout=undef, $eout=$ein, $tout=$tin);
344  
345 0 my $got = POSIX::read ($self->{FD}, $result, $wanted);
346  
347 0 ▶ unless (defined $got) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $got) 0 0 0
348 ## $got = -1; ## DEBUG
349 0 ▶ return (0,"") if (&POSIX::EAGAIN == ($ok = POSIX::errno()));
Branch: 1 branch
BranchTrueFalseTotal
if &POSIX::EAGAIN == ($ok = POSIX::errno()) 0 0 0
350 0 ▶ return (0,"") if (!$ready and (0 == $ok));
Branch: 1 branch
BranchTrueFalseTotal
if not $ready and 0 == $ok 0 0 0
Condition0%0/3
not $ready and 0 == $ok
!ll&&!rl&&r
000
MC/DC0%0/2
not $ready and 0 == $ok
not $ready 0 == $ok
Truth table0%0/3
not(A) and B
A= not $readyB= 0 == $ok
ABresult
0X0
100
111
351 # at least Solaris acts like eof() in this case
352 0 carp "Error #$ok in Device::SerialPort::read";
353 0 return;
354 }
355  
356 0 ▶ print "read_vmin=$got, ready=$ready, result=..$result..\n" if ($Babble);
Branch: 1 branch
BranchTrueFalseTotal
if $Babble 0 0 0
357 0 return ($got, $result);
358 }
359  
360 0 ▶sub input {
Subroutine input: not called CC=9 SCAR=45.0
Pod undocumented
361 0 ▶ return undef unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
362 0 my $self = shift;
363 0 my $ok = 0;
364 0 my $result = "";
365 0 my $wanted = 255;
366  
367 0 ▶ if (nocarp && $self->{"_T_INPUT"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (nocarp() and $self->{"_T_INPUT"}) 0 0 0
Condition0%0/3
nocarp() and $self->{"_T_INPUT"}
!ll&&!rl&&r
000
MC/DC0%0/2
nocarp() and $self->{"_T_INPUT"}
nocarp() $self->{"_T_INPUT"}
Truth table0%0/3
A and B
A= nocarp()B= $self->{"_T_INPUT"}
ABresult
0X0
100
111
368 0 $result = $self->{"_T_INPUT"};
369 0 $self->{"_T_INPUT"} = "";
370 0 return $result;
371 }
372  
373 0 ▶ if ( $self->{"C_VMIN"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"C_VMIN"}) 0 0 0
374 0 $self->{"C_VMIN"} = 0;
375 0 write_settings($self);
376 }
377  
378 0 my $got = POSIX::read ($self->{FD}, $result, $wanted);
379  
380 0 ▶ unless (defined $got) { $got = -1; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $got) 0 0 0
381 0 ▶ if ($got == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($got == -1) 0 0 0
382 0 ▶ return "" if (&POSIX::EAGAIN == ($ok = POSIX::errno()));
Branch: 1 branch
BranchTrueFalseTotal
if &POSIX::EAGAIN == ($ok = POSIX::errno()) 0 0 0
383 0 ▶ return "" if (0 == $ok); # at least Solaris acts like eof()
Branch: 1 branch
BranchTrueFalseTotal
if 0 == $ok 0 0 0
384 0 carp "Error #$ok in Device::SerialPort::input"
385 }
386 0 return $result;
387 }
388  
389 0 ▶sub write {
Subroutine write: not called CC=3 SCAR=24.8
Pod undocumented
390 0 ▶ return undef unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
391 0 my $self = shift;
392 0 my $wbuf = shift;
393 0 my $ok;
394  
395 0 ▶ return 0 if ($wbuf eq "");
Branch: 1 branch
BranchTrueFalseTotal
if $wbuf eq "" 0 0 0
396 0 my $lbuf = length ($wbuf);
397 0 my $written = POSIX::write ($self->{FD}, $wbuf, $lbuf);
398  
399 0 return $written;
400 }
401  
402 0 ▶sub write_drain {
Subroutine write_drain: not called CC=3 SCAR=24.8
Pod undocumented
403 0 my $self = shift;
404 0 ▶ return if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
405 0 ▶ return 1 if (defined POSIX::tcdrain($self->{FD}));
Branch: 1 branch
BranchTrueFalseTotal
if defined POSIX::tcdrain($self->{"FD"}) 0 0 0
406 0 return;
407 }
408  
409 0 ▶sub purge_all {
Subroutine purge_all: not called CC=3 SCAR=24.8
Pod undocumented
410 0 my $self = shift;
411 0 ▶ return if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
412 0 ▶ return 1 if (defined POSIX::tcflush($self->{FD}, TCIOFLUSH));
Branch: 1 branch
BranchTrueFalseTotal
if defined POSIX::tcflush($self->{"FD"}, 2) 0 0 0
413 0 return;
414 }
415  
416 0 ▶sub dtr_active {
Subroutine dtr_active: not called CC=6 SCAR=37.4
Pod undocumented
417 0 ▶ return unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
418 0 ▶ return unless ($bitset && $bitclear && $dtrout);
Branch: 1 branch
BranchTrueFalseTotal
unless $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout 0 0 0
Condition0%0/6
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear
!ll&&!rl&&r
000
MC/DC0%0/3
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout
$Ivrs::bitset $Ivrs::bitclear $Ivrs::dtrout
Truth table0%0/4
A and B and C
A= $Ivrs::bitsetB= $Ivrs::bitclearC= $Ivrs::dtrout
ABCresult
0XX0
10X0
1100
1111
419 0 my $self = shift;
420 0 my $onoff = shift;
421 # returns ioctl result
422 0 ▶ if ($onoff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($onoff) { } 0 0 0
423 0 ioctl($self->{HANDLE}, $bitset, $dtrout);
424 }
425 else {
426 0 ioctl($self->{HANDLE}, $bitclear, $dtrout);
427 }
428 }
429  
430 0 ▶sub rts_active {
Subroutine rts_active: not called CC=6 SCAR=37.4
Pod undocumented
431 0 ▶ return unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
432 0 ▶ return unless ($bitset && $bitclear && $rtsout);
Branch: 1 branch
BranchTrueFalseTotal
unless $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout 0 0 0
Condition0%0/6
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear
!ll&&!rl&&r
000
MC/DC0%0/3
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout
$Ivrs::bitset $Ivrs::bitclear $Ivrs::rtsout
Truth table0%0/4
A and B and C
A= $Ivrs::bitsetB= $Ivrs::bitclearC= $Ivrs::rtsout
ABCresult
0XX0
10X0
1100
1111
433 0 my $self = shift;
434 0 my $onoff = shift;
435 # returns ioctl result
436 0 ▶ if ($onoff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($onoff) { } 0 0 0
437 0 ioctl($self->{HANDLE}, $bitset, $rtsout);
438 }
439 else {
440 0 ioctl($self->{HANDLE}, $bitclear, $rtsout);
441 }
442 }
443  
444 0 ▶sub pulse_break_on {
Subroutine pulse_break_on: not called CC=3 SCAR=24.8
Pod undocumented
445 0 ▶ return unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
446 0 my $self = shift;
447 0 my $delay = (shift)/1000;
448 0 my $length = 0;
449 0 my $ok = POSIX::tcsendbreak($self->{FD}, $length);
450 0 ▶ warn "could not pulse break on" unless ($ok);
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
451 0 select (undef, undef, undef, $delay);
452 0 return $ok;
453 }
454  
455 0 ▶sub pulse_rts_on {
Subroutine pulse_rts_on: not called CC=7 SCAR=40.3
Pod undocumented
456 0 ▶ return unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
457 0 ▶ return unless ($bitset && $bitclear && $rtsout);
Branch: 1 branch
BranchTrueFalseTotal
unless $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout 0 0 0
Condition0%0/6
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear
!ll&&!rl&&r
000
MC/DC0%0/3
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout
$Ivrs::bitset $Ivrs::bitclear $Ivrs::rtsout
Truth table0%0/4
A and B and C
A= $Ivrs::bitsetB= $Ivrs::bitclearC= $Ivrs::rtsout
ABCresult
0XX0
10X0
1100
1111
458 0 my $self = shift;
459 0 my $delay = (shift)/1000;
460 0 ▶ $self->rts_active(1) or warn "could not pulse rts on";
Branch: 1 branch
BranchTrueFalseTotal
$self->rts_active(1) or warn "could not pulse rts on" 0 0 0
461 ## print "rts on\n"; ## DEBUG
462 0 select (undef, undef, undef, $delay);
463 0 ▶ $self->rts_active(0) or warn "could not restore from rts on";
Branch: 1 branch
BranchTrueFalseTotal
$self->rts_active(0) or warn "could not restore from rts on" 0 0 0
464 ## print "rts_off\n"; ## DEBUG
465 0 select (undef, undef, undef, $delay);
466 0 1;
467 }
468  
469 0 ▶sub pulse_dtr_on {
Subroutine pulse_dtr_on: not called CC=7 SCAR=40.3
Pod undocumented
470 0 ▶ return unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
471 0 ▶ return unless ($bitset && $bitclear && $dtrout);
Branch: 1 branch
BranchTrueFalseTotal
unless $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout 0 0 0
Condition0%0/6
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear
!ll&&!rl&&r
000
MC/DC0%0/3
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout
$Ivrs::bitset $Ivrs::bitclear $Ivrs::dtrout
Truth table0%0/4
A and B and C
A= $Ivrs::bitsetB= $Ivrs::bitclearC= $Ivrs::dtrout
ABCresult
0XX0
10X0
1100
1111
472 0 my $self = shift;
473 0 my $delay = (shift)/1000;
474 0 ▶ $self->dtr_active(1) or warn "could not pulse dtr on";
Branch: 1 branch
BranchTrueFalseTotal
$self->dtr_active(1) or warn "could not pulse dtr on" 0 0 0
475 ## print "dtr on\n"; ## DEBUG
476 0 select (undef, undef, undef, $delay);
477 0 ▶ $self->dtr_active(0) or warn "could not restore from dtr on";
Branch: 1 branch
BranchTrueFalseTotal
$self->dtr_active(0) or warn "could not restore from dtr on" 0 0 0
478 ## print "dtr_off\n"; ## DEBUG
479 0 select (undef, undef, undef, $delay);
480 0 1;
481 }
482  
483 0 ▶sub pulse_rts_off {
Subroutine pulse_rts_off: not called CC=7 SCAR=40.3
Pod undocumented
484 0 ▶ return unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
485 0 ▶ return unless ($bitset && $bitclear && $rtsout);
Branch: 1 branch
BranchTrueFalseTotal
unless $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout 0 0 0
Condition0%0/6
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear
!ll&&!rl&&r
000
MC/DC0%0/3
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::rtsout
$Ivrs::bitset $Ivrs::bitclear $Ivrs::rtsout
Truth table0%0/4
A and B and C
A= $Ivrs::bitsetB= $Ivrs::bitclearC= $Ivrs::rtsout
ABCresult
0XX0
10X0
1100
1111
486 0 my $self = shift;
487 0 my $delay = (shift)/1000;
488 0 ▶ $self->rts_active(0) or warn "could not pulse rts off";
Branch: 1 branch
BranchTrueFalseTotal
$self->rts_active(0) or warn "could not pulse rts off" 0 0 0
489 ## print "rts off\n"; ## DEBUG
490 0 select (undef, undef, undef, $delay);
491 0 ▶ $self->rts_active(1) or warn "could not restore from rts off";
Branch: 1 branch
BranchTrueFalseTotal
$self->rts_active(1) or warn "could not restore from rts off" 0 0 0
492 ## print "rts on\n"; ## DEBUG
493 0 select (undef, undef, undef, $delay);
494 0 1;
495 }
496  
497 0 ▶sub pulse_dtr_off {
Subroutine pulse_dtr_off: not called CC=7 SCAR=40.3
Pod undocumented
498 0 ▶ return unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
499 0 ▶ return unless ($bitset && $bitclear && $dtrout);
Branch: 1 branch
BranchTrueFalseTotal
unless $Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout 0 0 0
Condition0%0/6
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout
!ll&&!rl&&r
000
$Ivrs::bitset and $Ivrs::bitclear
!ll&&!rl&&r
000
MC/DC0%0/3
$Ivrs::bitset and $Ivrs::bitclear and $Ivrs::dtrout
$Ivrs::bitset $Ivrs::bitclear $Ivrs::dtrout
Truth table0%0/4
A and B and C
A= $Ivrs::bitsetB= $Ivrs::bitclearC= $Ivrs::dtrout
ABCresult
0XX0
10X0
1100
1111
500 0 my $self = shift;
501 0 my $delay = (shift)/1000;
502 0 ▶ $self->dtr_active(0) or warn "could not pulse dtr off";
Branch: 1 branch
BranchTrueFalseTotal
$self->dtr_active(0) or warn "could not pulse dtr off" 0 0 0
503 ## print "dtr off\n"; ## DEBUG
504 0 select (undef, undef, undef, $delay);
505 0 ▶ $self->dtr_active(1) or warn "could not restore from dtr off";
Branch: 1 branch
BranchTrueFalseTotal
$self->dtr_active(1) or warn "could not restore from dtr off" 0 0 0
506 ## print "dtr on\n"; ## DEBUG
507 0 select (undef, undef, undef, $delay);
508 0 1;
509 }
510 0 ▶sub baudrate {
Subroutine baudrate: not called CC=8 SCAR=42.8
Pod undocumented
511 0 my $self = shift;
512 0 my $item = 0;
513  
514 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
515 0 ▶ if (defined $bauds{$_[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bauds{$_[0]}) { } 0 0 0
516 0 $self->{"C_OSPEED"} = $bauds{$_[0]};
517 0 $self->{"C_ISPEED"} = $bauds{$_[0]};
518 0 write_settings($self);
519 }
520 else {
521 0 ▶ if ($self->{U_MSG} or $Babble) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"U_MSG"} or $Babble) 0 0 0
Condition0%0/3
$self->{"U_MSG"} or $Babble
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"U_MSG"} or $Babble
$self->{"U_MSG"} $Babble
Truth table0%0/3
A or B
A= $self->{"U_MSG"}B= $Babble
ABresult
1X1
011
000
522 0 carp "Can't set baudrate on $self->{ALIAS}";
523 }
524 0 return undef;
525 }
526 }
527 0 ▶ if (wantarray) { return (keys %bauds); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
528 0 foreach $item (keys %bauds) {
529 0 ▶ return $item if ($bauds{$item} == $self->{"C_OSPEED"});
Branch: 1 branch
BranchTrueFalseTotal
if $bauds{$item} == $self->{"C_OSPEED"} 0 0 0
530 }
531 0 return undef;
532 }
533 0 ▶sub parity_enable {
Subroutine parity_enable: not called CC=4 SCAR=30.0
Pod undocumented
534 0 my $self = shift;
535 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
536 0 ▶ if ( yes_true( shift ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (yes_true(shift())) { } 0 0 0
537 0 $self->{"C_IFLAG"} |= PARMRK;
538 0 $self->{"C_CFLAG"} |= PARENB;
539 } else {
540 0 $self->{"C_IFLAG"} &= ~PARMRK;
541 0 $self->{"C_CFLAG"} &= ~PARENB;
542 }
543 0 write_settings($self);
544 }
545 0 ▶ return wantarray ? @binary_opt : ($self->{"C_CFLAG"} & PARENB);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
546 }
547  
548 0 ▶sub parity {
Subroutine parity: not called CC=11 SCAR=48.8
Pod undocumented
549 0 my $self = shift;
550 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
551 0 ▶ if ( $_[0] eq "none" ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($_[0] eq 'none') { } 0 0 0
elsif ($_[0] eq 'odd') { } 0 0 0
elsif ($_[0] eq 'even') { } 0 0 0
552 0 $self->{"C_IFLAG"} &= ~INPCK;
553 0 $self->{"C_CFLAG"} &= ~PARENB;
554 }
555 elsif ( $_[0] eq "odd" ) {
556 0 $self->{"C_IFLAG"} |= INPCK;
557 0 $self->{"C_CFLAG"} |= (PARENB|PARODD);
558 }
559 elsif ( $_[0] eq "even" ) {
560 0 $self->{"C_IFLAG"} |= INPCK;
561 0 $self->{"C_CFLAG"} |= PARENB;
562 0 $self->{"C_CFLAG"} &= ~PARODD;
563 }
564 else {
565 0 ▶ if ($self->{U_MSG} or $Babble) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"U_MSG"} or $Babble) 0 0 0
Condition0%0/3
$self->{"U_MSG"} or $Babble
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"U_MSG"} or $Babble
$self->{"U_MSG"} $Babble
Truth table0%0/3
A or B
A= $self->{"U_MSG"}B= $Babble
ABresult
1X1
011
000
566 0 carp "Can't set parity on $self->{ALIAS}";
567 }
568 0 return;
569 }
570 0 write_settings($self);
571 }
572 0 ▶ if (wantarray) { return ("none", "odd", "even"); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
573 0 ▶ return "none" unless ($self->{"C_IFLAG"} & INPCK);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"C_IFLAG"} & 16 0 0 0
574 0 my $mask = (PARENB|PARODD);
575 0 ▶ return "odd" if ($mask == ($self->{"C_CFLAG"} & $mask));
Branch: 1 branch
BranchTrueFalseTotal
if $mask == ($self->{"C_CFLAG"} & $mask) 0 0 0
576 0 $mask = (PARENB);
577 0 ▶ return "even" if ($mask == ($self->{"C_CFLAG"} & $mask));
Branch: 1 branch
BranchTrueFalseTotal
if $mask == ($self->{"C_CFLAG"} & $mask) 0 0 0
578 0 return "none";
579 }
580  
581 0 ▶sub databits {
Subroutine databits: not called CC=12 SCAR=50.5
Pod undocumented
582 0 my $self = shift;
583 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
584 0 ▶ if ( $_[0] == 8 ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($_[0] == 8) { } 0 0 0
elsif ($_[0] == 7) { } 0 0 0
elsif ($_[0] == 6) { } 0 0 0
elsif ($_[0] == 5) { } 0 0 0
585 0 $self->{"C_CFLAG"} &= ~CSIZE;
586 0 $self->{"C_CFLAG"} |= CS8;
587 }
588 elsif ( $_[0] == 7 ) {
589 0 $self->{"C_CFLAG"} &= ~CSIZE;
590 0 $self->{"C_CFLAG"} |= CS7;
591 }
592 elsif ( $_[0] == 6 ) {
593 0 $self->{"C_CFLAG"} &= ~CSIZE;
594 0 $self->{"C_CFLAG"} |= CS6;
595 }
596 elsif ( $_[0] == 5 ) {
597 0 $self->{"C_CFLAG"} &= ~CSIZE;
598 0 $self->{"C_CFLAG"} |= CS5;
599 }
600 else {
601 0 ▶ if ($self->{U_MSG} or $Babble) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"U_MSG"} or $Babble) 0 0 0
Condition0%0/3
$self->{"U_MSG"} or $Babble
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"U_MSG"} or $Babble
$self->{"U_MSG"} $Babble
Truth table0%0/3
A or B
A= $self->{"U_MSG"}B= $Babble
ABresult
1X1
011
000
602 0 carp "Can't set databits on $self->{ALIAS}";
603 }
604 0 return;
605 }
606 0 write_settings($self);
607 }
608 0 ▶ if (wantarray) { return (5, 6, 7, 8); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
609 0 my $mask = ($self->{"C_CFLAG"} & CSIZE);
610 0 ▶ return 8 if ($mask == CS8);
Branch: 1 branch
BranchTrueFalseTotal
if $mask == 48 0 0 0
611 0 ▶ return 7 if ($mask == CS7);
Branch: 1 branch
BranchTrueFalseTotal
if $mask == 32 0 0 0
612 0 ▶ return 6 if ($mask == CS6);
Branch: 1 branch
BranchTrueFalseTotal
if $mask == 16 0 0 0
613 0 return 5;
614 }
615  
616 0 ▶sub stopbits {
Subroutine stopbits: not called CC=8 SCAR=42.8
Pod undocumented
617 0 my $self = shift;
618 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
619 0 ▶ if ( $_[0] == 2 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_[0] == 2) { } 0 0 0
elsif ($_[0] == 1) { } 0 0 0
620 0 $self->{"C_CFLAG"} |= CSTOPB;
621 }
622 elsif ( $_[0] == 1 ) {
623 0 $self->{"C_CFLAG"} &= ~CSTOPB;
624 }
625 else {
626 0 ▶ if ($self->{U_MSG} or $Babble) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"U_MSG"} or $Babble) 0 0 0
Condition0%0/3
$self->{"U_MSG"} or $Babble
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"U_MSG"} or $Babble
$self->{"U_MSG"} $Babble
Truth table0%0/3
A or B
A= $self->{"U_MSG"}B= $Babble
ABresult
1X1
011
000
627 0 carp "Can't set stopbits on $self->{ALIAS}";
628 }
629 0 return;
630 }
631 0 write_settings($self);
632 }
633 0 ▶ if (wantarray) { return (1, 2); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
634 0 ▶ return 2 if ($self->{"C_CFLAG"} & CSTOPB);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"C_CFLAG"} & 64 0 0 0
635 0 return 1;
636 }
637
638 0 ▶sub handshake {
Subroutine handshake: not called CC=10 SCAR=47.0
Pod undocumented
639 0 my $self = shift;
640
641 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
642 0 ▶ if ( $_[0] eq "none" ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($_[0] eq 'none') { } 0 0 0
elsif ($_[0] eq 'xoff') { } 0 0 0
elsif ($_[0] eq 'rts') { } 0 0 0
643 0 $self->{"C_IFLAG"} &= ~(IXON | IXOFF);
644 0 $self->{"C_CFLAG"} &= ~CRTSCTS;
645 }
646 elsif ( $_[0] eq "xoff" ) {
647 0 $self->{"C_IFLAG"} |= (IXON | IXOFF);
648 0 $self->{"C_CFLAG"} &= ~CRTSCTS;
649 }
650 elsif ( $_[0] eq "rts" ) {
651 0 $self->{"C_IFLAG"} &= ~(IXON | IXOFF);
652 0 $self->{"C_CFLAG"} |= CRTSCTS;
653 }
654 else {
655 0 ▶ if ($self->{U_MSG} or $Babble) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"U_MSG"} or $Babble) 0 0 0
Condition0%0/3
$self->{"U_MSG"} or $Babble
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"U_MSG"} or $Babble
$self->{"U_MSG"} $Babble
Truth table0%0/3
A or B
A= $self->{"U_MSG"}B= $Babble
ABresult
1X1
011
000
656 0 carp "Can't set handshake on $self->{ALIAS}";
657 }
658 0 return;
659 }
660 0 write_settings($self);
661 }
662 0 ▶ if (wantarray) { return ("none", "xoff", "rts"); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
663 0 my $mask = (IXON|IXOFF);
664 0 ▶ return "xoff" if ($mask == ($self->{"C_IFLAG"} & $mask));
Branch: 1 branch
BranchTrueFalseTotal
if $mask == ($self->{"C_IFLAG"} & $mask) 0 0 0
665 0 ▶ return "rts" if ($self->{"C_CFLAG"} & CRTSCTS);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"C_CFLAG"} & CRTSCTS() 0 0 0
666 0 return "none";
667 }
668  
669 0 ▶sub buffers {
Subroutine buffers: not called CC=4 SCAR=30.0
Pod undocumented
670 0 my $self = shift;
671 0 ▶ if (@_) { return unless (@_ == 2); }
Branch: 2 branches
BranchTrueFalseTotal
if (@_) 0 0 0
unless @_ == 2 0 0 0
672 0 ▶ return wantarray ? (4096, 4096) : 1;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
673 }
674  
675 0 ▶sub pclose {
Subroutine pclose: not called CC=9 SCAR=45.0
Pod undocumented
676 0 my $self = shift;
677 0 my $ok = undef;
678 0 my $item;
679  
680 0 ▶ return unless (defined $self->{NAME});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"NAME"} 0 0 0
681  
682 0 ▶ if ($Babble) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Babble) 0 0 0
683 0 carp "Closing $self " . $self->{ALIAS};
684 }
685 0 ▶ if ($self->{FD}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"FD"}) 0 0 0
686 0 purge_all ($self);
687  
688 # copy the original values into "current" values
689 0 foreach $item (keys %c_cc_fields) {
690 0 $self->{"C_$item"} = $self->{"_$item"};
691 }
692  
693 0 $self->{"C_CFLAG"} = $self->{"_CFLAG"};
694 0 $self->{"C_IFLAG"} = $self->{"_IFLAG"};
695 0 $self->{"C_ISPEED"} = $self->{"_ISPEED"};
696 0 $self->{"C_LFLAG"} = $self->{"_LFLAG"};
697 0 $self->{"C_OFLAG"} = $self->{"_OFLAG"};
698 0 $self->{"C_OSPEED"} = $self->{"_OSPEED"};
699
700 0 write_settings($self);
701  
702 0 $ok = POSIX::close($self->{FD});
703 # also closes $self->{HANDLE}
704  
705 0 $self->{FD} = undef;
706 }
707 0 ▶ if ($self->{LOCK}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"LOCK"}) 0 0 0
708 0 ▶ unless ( unlink $self->{LOCK} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (unlink $self->{"LOCK"}) 0 0 0
709 0 ▶ nocarp or carp "can't remove lockfile: $self->{LOCK}\n";
Branch: 1 branch
BranchTrueFalseTotal
nocarp() or carp(qq[can't remove lockfile: $self->{"LOCK"}\n]) 0 0 0
710 }
711 0 $self->{LOCK} = "";
712 }
713 0 $self->{NAME} = undef;
714 0 $self->{ALIAS} = undef;
715 0 close (LOG);
716 0 ▶ return unless ($ok);
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
717 # exit 0;
718 }
719  
720 #My routines starts from here, Not a very tight code, but it works!!
721 #
722 #---------------------------------------------------------------------#
723 0 ▶sub initmodem {
Subroutine initmodem: not called CC=8 SCAR=42.8
Pod undocumented
724 0 my $self=shift;
725 0 ▶ $self->pulse_dtr_on(500)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->pulse_dtr_on(500) or return undef 0 0 0
726 0 ▶ $self->pulse_dtr_off(500)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->pulse_dtr_off(500) or return undef 0 0 0
727 0 ▶ $self->atcomm("ATZ","OK") ||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("ATZ", "OK") or return undef 0 0 0
728 0 ▶ $self->atcomm("AT&C1&D2&K3M2L3","OK")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT&C1&D2&K3M2L3", "OK") or return undef 0 0 0
729 0 ▶ $self->atcomm("AT#CLS=8","OK")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#CLS=8", "OK") or return undef 0 0 0
730 #These are some of the Rockwell specific commands, enable them if your
731 #Modem does not work.
732 # $self->atcomm("AT","OK")||return undef;
733 # $self->atcomm("AT#VBS=4","OK")||return undef;
734 # $self->atcomm("AT#VSP=2","OK")||return undef;
735 # $self->atcomm("AT#VTD=3F,3F,3F","OK")||return undef;
736 # $self->atcomm("AT#VSR=7200","OK")||return undef;
737 # $self->atcomm("AT#VSD=1","OK")||return undef;
738 # $self->atcomm("AT#BDR=0","OK")||return undef;
739  
740 #These are some of the USRobotic specific commands, enable them if your
741 #Modem does not work.
742 # $self->atcomm("AT#VTM=0","OK")||return undef;
743 # $self->atcomm("AT#VSR=8000","OK")||return undef;
744 # $self->atcomm("AT#VGT=255","OK")||return undef;
745  
746 #Do not comment out these!!
747 0 ▶ $self->atcomm("AT#VLS=2","VCON")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VLS=2", "VCON") or return undef 0 0 0
748 0 ▶ $self->atcomm("ATL3","OK")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("ATL3", "OK") or return undef 0 0 0
749 0 unlink("$tmpmsg");
750 0 print LOG "Port Configured for Voice \n";
751 }
752  
753 0 ▶sub setport {
Subroutine setport: not called CC=7 SCAR=40.3
Pod undocumented
754 0 my $self=shift;
755 0 my $baud=shift;
756 0 my $parity=shift;
757 0 my $data=shift;
758 0 my $stop=shift;
759 0 my $hand=shift;
760 0 my $buff=shift;
761 0 ▶ $self->baudrate($baud)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->baudrate($baud) or return undef 0 0 0
762 0 ▶ $self->parity($parity)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->parity($parity) or return undef 0 0 0
763 0 ▶ $self->databits($data)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->databits($data) or return undef 0 0 0
764 0 ▶ $self->stopbits($stop)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->stopbits($stop) or return undef 0 0 0
765 0 ▶ $self->handshake($hand)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->handshake($hand) or return undef 0 0 0
766 #$self->buffers($buff,$buff)||return undef;
767 0 ▶ $self->buffers(0,0)||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->buffers(0, 0) or return undef 0 0 0
768 0 $self->write_settings;
769 0 print LOG "Port Configuration changed\n";
770 0 return 1;
771 }
772
773 0 ▶sub waitring {
Subroutine waitring: not called CC=7 SCAR=40.3
Pod undocumented
774 0 my $self=shift;
775 0 my $callid="";
776 0 print LOG "Waiting for ring from ",`date`;
777 0 ▶ $self->atcomm("AT#VLS=0","OK")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VLS=0", "OK") or return undef 0 0 0
778 0 ▶ $self->atcomm("AT#CLS=8","OK")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#CLS=8", "OK") or return undef 0 0 0
779 0 ▶ while (!($self->input=~/[RING]/)){sleep 1;}
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->input =~ /[RING]/) 0 0 0
780 0 $callid=$self->input;
781 0 ▶ $self->atcomm("ATA","")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("ATA", "") or return undef 0 0 0
782 0 ▶ $self->atcomm("AT#VLS=2","VCON")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VLS=2", "VCON") or return undef 0 0 0
783 0 ▶ $self->atcomm("AT#VTX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VTX", "CONNECT") or return undef 0 0 0
784 0 print LOG "Call from <$callid> received at ",`date`;
785 0 return $callid;
786 }
787  
788 sub dialout
789 0 ▶{
Subroutine dialout: not called CC=3 SCAR=24.8
Pod undocumented
790 #This is experimental only. Most of the modem fail to detect ring back,
791 #and pick up, even before the receiver is lifted by called number.
792 0 my $self=shift;
793 0 my $telno = shift;
794 0 my $ddelay=shift;
795 0 my $cstring ="ATX1DT".$telno;
796 0 $self->atcomm("ATZ","OK");
797 # $self->atcomm("AT#VRA=45","OK");
798 # $self->atcomm("AT#VRN=250","OK");
799 0 $self->atcomm("AT#VLS=0","OK");
800 0 $self->atcomm("AT#CLS=8","OK");
801 0 $self->atcomm("AT","OK");
802 0 $self->atcomm($cstring,"VCON",$ddelay);
803 0 sleep 5;
804 # $self->atcomm("AT#VLS=2","OK")||return undef;
805 0 ▶ $self->atcomm("AT#VTX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VTX", "CONNECT") or return undef 0 0 0
806 0 ▶ print LOG "Dialing $telno \n" if $Babble;
Branch: 1 branch
BranchTrueFalseTotal
if $Babble 0 0 0
807  
808 }
809  
810 sub callxfer
811 0 ▶{
Subroutine callxfer: not called CC=3 SCAR=24.8
Pod undocumented
812  
813 #This is experimental only. Most of the modem fail to detect ring back,
814 #and pick up, even before the receiver is lifted by called number.
815  
816 0 my $self=shift;
817 0 my $telno = shift;
818 0 $self->atcomm("\020\003\020\003","VCON");
819 0 my $cstring ="ATX1DT".$telno;
820 0 $self->atcomm("AT#VLS=0","OK");
821 0 $self->atcomm("AT#CLS=8","OK");
822 0 $self->atcomm("ATDP1","");
823 0 $self->atcomm($cstring,"OK","20");
824 0 ▶ $self->atcomm("ATH","OK")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("ATH", "OK") or return undef 0 0 0
825 0 ▶ print LOG "Transfered to $telno \n" if $Babble;
Branch: 1 branch
BranchTrueFalseTotal
if $Babble 0 0 0
826 }
827  
828 0 ▶sub atcomm {
Subroutine atcomm: not called CC=6 SCAR=37.4
Pod undocumented
829 0 my $self=shift;
830 0 my $atstr=shift;
831 0 my $waitfor=shift;
832 0 my $dialdelay=shift;
833 0 my $oltime=time;
834 0 my $mdtime=5;
835 0 ▶ $mdtime=$dialdelay if ($dialdelay);
Branch: 1 branch
BranchTrueFalseTotal
if $dialdelay 0 0 0
836 0 my $getstr="";
837 #$atstr=$atstr."AT\r";
838 0 $self->write("$atstr\r");
839 0 ▶ while (!($getstr=~/$waitfor/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($getstr =~ /$waitfor/) 0 0 0
840 0 $getstr=$getstr.$self->input;
841 0 ▶ if (((time - $oltime)>$mdtime)||($getstr=~/[b]/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (time - $oltime > $mdtime or $getstr =~ /[b]/) 0 0 0
Condition0%0/3
time - $oltime > $mdtime or $getstr =~ /[b]/
l!l&&r!l&&!r
000
MC/DC0%0/2
time - $oltime > $mdtime or $getstr =~ /[b]/
time - $oltime > $mdtime $getstr =~ /[b]/
Truth table0%0/3
A or B
A= time - $oltime > $mdtimeB= $getstr =~ /[b]/
ABresult
1X1
011
000
842 0 print LOG "Modem failed to reply <$atstr> \n";
843 #$self->pclose ;
844 0 return undef;
845 }
846 }
847 #return $getstr;
848 0 ▶ print LOG "Modem->$getstr" if $Babble;
Branch: 1 branch
BranchTrueFalseTotal
if $Babble 0 0 0
849 0 return 1;
850 }
851  
852 0 ▶sub faxmode {
Subroutine faxmode: not called CC=2 SCAR=17.9
Pod undocumented
853 0 my $self=shift;
854 0 $self->atcomm("\020\003\020\003","VCON");
855 0 $self->atcomm("AT#BDR=0","OK");
856 0 $self->atcomm("AT#CLS=0","OK");
857 0 $self->atcomm("AT+FCLASS=1","OK");
858 0 ▶ print LOG "Fax mode set \n" if $Babble;
Branch: 1 branch
BranchTrueFalseTotal
if $Babble 0 0 0
859 }
860  
861 0 ▶sub playfile {
Subroutine playfile: not called CC=29 SCAR=67.7
Pod undocumented
862 0 my $self=shift;
863 0 my $pfile=shift;
864 0 my $playfile="";
865 0 ▶ $pfile="" if !($pfile);
Branch: 1 branch
BranchTrueFalseTotal
unless $pfile 0 0 0
866 0 $playfile=$pfile;
867 0 ▶ $playfile="$vdir/$pfile" if (substr($pfile,0,1) ne "/");
Branch: 1 branch
BranchTrueFalseTotal
if substr($pfile, 0, 1) ne "/" 0 0 0
868 0 ▶ $playfile=$tmpmsg if ($pfile eq "");
Branch: 1 branch
BranchTrueFalseTotal
if $pfile eq "" 0 0 0
869 0 ▶ if (!(-e $playfile)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $playfile) 0 0 0
870 0 print LOG "play->File $playfile not found\n";
871 0 return undef;
872 }
873 0 ▶ print LOG "play->The play file is $playfile \n" if $Babble;
Branch: 1 branch
BranchTrueFalseTotal
if $Babble 0 0 0
874 0 my $ndtmf=shift;
875 0 ▶ $ndtmf=0 if !($ndtmf);
Branch: 1 branch
BranchTrueFalseTotal
unless $ndtmf 0 0 0
876 0 my $rdtmf="";
877 0 my $dtmf="";
878 0 my $tmp;
879 0 my $dtcount =0;
880 0 open (FH1,$playfile);
881 0 $self->write($rmdhdr);
882 0 $self->write_drain;
883 0 ▶ while (!eof(FH1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eof FH1) 0 0 0
884 0 read FH1,$tmp,1000;
885 0 $self->write($tmp);
886 0 $self->write_drain;
887 0 $dtmf=$self->input;
888 0 ▶ last if ($dtmf=~/[0-9]/) && ($ndtmf !=0);
Branch: 1 branch
BranchTrueFalseTotal
if $dtmf =~ /[0-9]/ and $ndtmf != 0 0 0 0
Condition0%0/3
$dtmf =~ /[0-9]/ and $ndtmf != 0
!ll&&!rl&&r
000
MC/DC0%0/2
$dtmf =~ /[0-9]/ and $ndtmf != 0
$dtmf =~ /[0-9]/ $ndtmf != 0
Truth table0%0/3
A and B
A= $dtmf =~ /[0-9]/B= $ndtmf != 0
ABresult
0X0
100
111
889 0 ▶ if ($dtmf=~/[b]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtmf =~ /[b]/) 0 0 0
890 0 print LOG "Call->User hanged up before call was finished\n";
891 0 return undef;
892 }
893 }
894 0 ▶ unlink("$tmpmsg") if $playfile eq "$tmpmsg";
Branch: 1 branch
BranchTrueFalseTotal
if $playfile eq "$tmpmsg" 0 0 0
895 0 ▶ if ($ndtmf == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ndtmf == 0) 0 0 0
896 0 ▶ $self->atcomm("\020\030\020\003","VCON") ||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("\20\30\20\3", "VCON") or return undef 0 0 0
897 0 ▶ $self->atcomm("AT#VTX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VTX", "CONNECT") or return undef 0 0 0
898 0 return 1;
899 }
900 0 ▶ if ($ndtmf==1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ndtmf == 1) 0 0 0
901 0 ▶ $self->atcomm("\020\030\020\003","VCON") ||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("\20\30\20\3", "VCON") or return undef 0 0 0
902 0 ▶ $self->atcomm("AT#VTX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VTX", "CONNECT") or return undef 0 0 0
903 0 ▶ return join('', split(/\W/,$dtmf)) if $dtmf;
Branch: 1 branch
BranchTrueFalseTotal
if $dtmf 0 0 0
904 0 return " ";
905 }
906 0 $rdtmf=$dtmf;
907 0 ▶ $self->atcomm("\020\030\020\003","VCON") ||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("\20\30\20\3", "VCON") or return undef 0 0 0
908 0 ▶ $self->atcomm("AT#VTX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VTX", "CONNECT") or return undef 0 0 0
909 0 open (FH1,"$vdir/tsil15");
910 0 ▶ while (!eof(FH1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eof FH1) 0 0 0
911 0 read FH1,$tmp,1000;
912 0 $self->write($tmp);
913 0 $self->write_drain;
914 0 $dtmf=$self->input;
915 0 ▶ $rdtmf=$rdtmf.$dtmf if ($dtmf=~/[0-9]/);
Branch: 1 branch
BranchTrueFalseTotal
if $dtmf =~ /[0-9]/ 0 0 0
916 0 ▶ if ($dtmf=~/[b]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtmf =~ /[b]/) 0 0 0
917 0 print LOG "Call->User hanged up before call was finished\n";
918 0 return undef;
919 }
920 0 ▶ last if (length($rdtmf)==$ndtmf*2) or ($dtmf=~/[#\*]/);
Branch: 1 branch
BranchTrueFalseTotal
if length $rdtmf == $ndtmf * 2 or $dtmf =~ /[#\*]/ 0 0 0
Condition0%0/3
length $rdtmf == $ndtmf * 2 or $dtmf =~ /[#\*]/
l!l&&r!l&&!r
000
MC/DC0%0/2
length $rdtmf == $ndtmf * 2 or $dtmf =~ /[#\*]/
length $rdtmf == $ndtmf * 2 $dtmf =~ /[#\*]/
Truth table0%0/3
A or B
A= length $rdtmf == $ndtmf * 2B= $dtmf =~ /[#\*]/
ABresult
1X1
011
000
921 }
922 0 ▶ $self->atcomm("\020\030\020\003","VCON") ||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("\20\30\20\3", "VCON") or return undef 0 0 0
923 0 ▶ $self->atcomm("AT#VTX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VTX", "CONNECT") or return undef 0 0 0
924 0 ▶ return " " if !($rdtmf=~/[0-9]/);
Branch: 1 branch
BranchTrueFalseTotal
unless $rdtmf =~ /[0-9]/ 0 0 0
925 0 return join('', split(/\W/, $rdtmf));
926 }
927  
928 0 ▶sub recfile {
Subroutine recfile: not called CC=6 SCAR=37.4
Pod undocumented
929 0 my $self=shift;
930 0 my $recfile = shift;
931 0 my $ttime=shift;
932 0 $self->atcomm("\020\003\020\003","VCON");
933 0 ▶ $self->atcomm("AT#VRX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VRX", "CONNECT") or return undef 0 0 0
934 0 open (FH1,">$recfile");
935 0 print FH1 $rmdhdr;
936 0 my $otimer=time;
937 0 ▶ while ((time-$otimer)<$ttime) {
Branch: 1 branch
BranchTrueFalseTotal
if (time - $otimer < $ttime) 0 0 0
938 0 print FH1 $self->input;
939 }
940 0 close FH1;
941 0 ▶ if ($self->input=~/[b]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->input =~ /[b]/) 0 0 0
942 0 print LOG "Call->User hanged up before call was finished\n";
943 0 return undef;
944 }
945 0 print LOG "Message file $recfile recorded\n";
946 0 ▶ $self->atcomm("\020\030\020\003","VCON")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("\20\30\20\3", "VCON") or return undef 0 0 0
947 0 ▶ $self->atcomm("AT#VTX","CONNECT")||return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->atcomm("AT#VTX", "CONNECT") or return undef 0 0 0
948 0 return 1;
949 }
950  
951 0 ▶sub addmsg {
Subroutine addmsg: not called CC=3 SCAR=24.8
Pod undocumented
952 0 my $self=shift;
953 0 my $playfile=shift;
954 0 my $self1=shift;
955 0 my $tmp="";
956 0 open (FHO, ">>$tmpmsg");
957 0 open (FHI, "<$vdir/$playfile");
958 0 ▶ while (!eof(FHI)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eof FHI) 0 0 0
959 0 read FHI,$tmp,1000;
960 0 print FHO $tmp;
961 }
962 0 close (FHI);
963 0 close (FHO);
964 0 ▶ print LOG "Msg->$playfile added\n" if $Babble;
Branch: 1 branch
BranchTrueFalseTotal
if $Babble 0 0 0
965 }
966  
967 0 ▶sub addval {
Subroutine addval: not called CC=4 SCAR=30.0
Pod undocumented
968 0 my $self=shift;
969 0 my $num1=shift;
970 0 my $num2;
971 my $num3;
972 0 ▶ $num1="0".$num1 while (length($num1) ne 9);
Branch: 1 branch
BranchTrueFalseTotal
length $num1 ne 9 and do { $num1 = '0' . $num1 } 0 0 0
973 0 $num2=substr($num1,0,2);
974 0 $self->addint1($num2,"crore");
975 0 $num2=substr($num1,2,2);
976 0 $self->addint1($num2,"lack");
977 0 $num2=substr($num1,4,2);
978 0 $self->addint1($num2,"thousand");
979 0 $num2=substr($num1,6,1);
980 0 ▶ $self->addmsg($num2) if ($num2 != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num2 != 0 0 0 0
981 0 ▶ $self->addmsg("hundred") if ($num2 != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num2 != 0 0 0 0
982 0 $num2=substr($num1,7,2);
983 0 $self->addint1($num2,"sil0");
984 0 return ;
985 }
986  
987 0 ▶sub addint1 {
Subroutine addint1: not called CC=6 SCAR=37.4
Pod undocumented
988 0 my $self=shift;
989 0 my $num2=shift;
990 0 my $unit=shift;
991 0 my $num3;
992 0 ▶ if (($num2<21)&&($num2>0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num2 < 21 and $num2 > 0) 0 0 0
Condition0%0/3
$num2 < 21 and $num2 > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$num2 < 21 and $num2 > 0
$num2 < 21 $num2 > 0
Truth table0%0/3
A and B
A= $num2 < 21B= $num2 > 0
ABresult
0X0
100
111
993 0 $num2=int($num2);
994 0 $self->addmsg($num2);
995 }
996 0 ▶ if ($num2>20) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num2 > 20) 0 0 0
997 0 $num3=10*substr($num2,0,1);
998 0 $self->addmsg($num3);
999 0 $num3=substr($num2,1,1);
1000 0 ▶ $self->addmsg($num3) if ($num3 !=0);
Branch: 1 branch
BranchTrueFalseTotal
if $num3 != 0 0 0 0
1001 }
1002 0 ▶ $self->addmsg($unit) if ($num2 != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num2 != 0 0 0 0
1003 0 return;
1004 }
1005  
1006 0 ▶sub addmil {
Subroutine addmil: not called CC=2 SCAR=17.9
Pod undocumented
1007 0 my $self=shift;
1008 0 my $num1=shift;
1009 0 my $num2;
1010 my $num3;
1011 0 ▶ $num1="0".$num1 while (length($num1) ne 9);
Branch: 1 branch
BranchTrueFalseTotal
length $num1 ne 9 and do { $num1 = '0' . $num1 } 0 0 0
1012 0 $num2=substr($num1,0,3);
1013 0 $self->addint2($num2,"crore");
1014 0 $num2=substr($num1,3,3);
1015 0 $self->addint2($num2,"thousand");
1016 0 $num2=substr($num1,6,3);
1017 0 $self->addint2($num2,"sil0");
1018 0 return ;
1019 }
1020  
1021 0 ▶sub addint2 {
Subroutine addint2: not called CC=8 SCAR=42.8
Pod undocumented
1022 0 my $self=shift;
1023 0 my $num2=shift;
1024 0 my $unit=shift;
1025 0 my $num3=0;
1026 0 $num3=substr($num2,0,1);
1027 0 ▶ $self->addmsg($num3) if ($num3 != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num3 != 0 0 0 0
1028 0 ▶ $self->addmsg("hundred") if ($num3 != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num3 != 0 0 0 0
1029 0 $num2=substr($num2,1,2);
1030 0 ▶ if (($num2<21)&&($num2>0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num2 < 21 and $num2 > 0) 0 0 0
Condition0%0/3
$num2 < 21 and $num2 > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$num2 < 21 and $num2 > 0
$num2 < 21 $num2 > 0
Truth table0%0/3
A and B
A= $num2 < 21B= $num2 > 0
ABresult
0X0
100
111
1031 0 $num2=int($num2);
1032 0 $self->addmsg($num2);
1033 }
1034 0 ▶ if ($num2>20) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num2 > 20) 0 0 0
1035 0 $num3=10*substr($num2,0,1);
1036 0 $self->addmsg($num3);
1037 0 $num3=substr($num2,1,1);
1038 0 ▶ $self->addmsg($num3) if ($num3 !=0);
Branch: 1 branch
BranchTrueFalseTotal
if $num3 != 0 0 0 0
1039 }
1040 0 ▶ $self->addmsg($unit) if ($num2 != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num2 != 0 0 0 0
1041 0 return;
1042 }
1043  
1044 0 ▶sub addtxt {
Subroutine addtxt: not called CC=2 SCAR=17.9
Pod undocumented
1045 0 my $self = shift;
1046 0 my $pstr = shift;
1047 0 my $i=0;
1048 0 my $pchr="";
1049 0 ▶ while ($i!=length($pstr)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i != length $pstr) 0 0 0
1050 0 $pchr=lc(substr($pstr,$i,1));
1051 0 $self->addmsg($pchr);
1052 0 $i++;
1053 }
1054 }
1055  
1056 0 ▶sub addate {
Subroutine addate: not called CC=1 SCAR=6.9
Pod undocumented
1057 0 my $self=shift;
1058 0 my $num1=shift;
1059 0 my $num2="";
1060 0 $num2=substr($num1,0,2);
1061 0 $self->addval($num2);
1062 0 $num2=substr($num1,2,2);
1063 #$num2=abs($num2);
1064 0 $num2="m$num2";
1065 0 $self->addmsg($num2);
1066 0 $num2=substr($num1,4,4);
1067 #$num2=substr($num1,2,2) if (substr($num1,0,2) eq 19);
1068 0 $self->addval($num2);
1069 0 return;
1070 }
1071  
1072  
1073 0 ▶sub closep {
Subroutine closep: not called CC=1 SCAR=6.9
Pod undocumented
1074 0 my $self=shift;
1075 0 unlink ("$tmpmsg");
1076 0 unlink ("$tmpmsg.1");
1077 0 unlink ("$tmpmsg.2");
1078 0 $self->atcomm("\020\030\020\003","VCON");
1079 0 $self->atcomm("ATH","OK");
1080 0 $self->atcomm("ATZ","OK");
1081 0 $self->pclose
1082 }
1083  
1084  
1085 1 1;
1086 __END__
↑ Summary