Connection/RS232.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 CC 2 SCAR 12.0
CC
2
Cov
0%
new
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 #
2 # This is the RS232 Connection base class. It provides the interface definition for all
3 # connections implementing access via a RS232 line with its typical properties
4 # (baud rate, stop bits, ...)
5 #
6 # In your scripts, use the implementing classes (e.g. Lab::Connection::VISA_RS232).
7 #
8 # Instruments using a RS232 connection will check the inheritance tree of the provided connection
9 # for this class.
10 #
11  
12 # TODO: a lot, ...
13  
14 package Lab::Connection::RS232;
15 #ABSTRACT: RS232 Connection base class
16 $Lab::Connection::RS232::VERSION = '3.899';
17 use v5.20;
18  
19 use Lab::Connection;
20 use strict;
21 use Lab::Exception;
22  
23 our @ISA = ("Lab::Connection");
24  
25 our %fields = (
26 bus_class => 'Lab::Bus::RS232',
27 port => undef,
28 brutal => 0,
29 read_length => 1000, # bytes
30 );
31  
32 sub new {
33 my $proto = shift;
34 my $class = ref($proto) || $proto;
35 my $self = $class->SUPER::new(@_)
36 ; # getting fields and _permitted from parent class
37 $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
38  
39 # Parameter checking
40 if ( !defined $self->config('port') ) {
41 Lab::Exception::CorruptParameter->throw(
42 error => "No RS232 port specified! I can't work like this.\n" );
43 }
44  
45 return $self;
46 }
47  
48 #
49 # These are the method stubs you have to overwrite when implementing the RS232 connection for your
50 # hardware/driver. See documentation for detailed description of the parameters, expected exceptions
51 # and expected return values.
52 #
53 # You might just be satisfied with the generic ones from Lab::Connection, take a look at them.
54 #
55  
56 # sub Clear { # @_ = ()
57 # return 0;
58 # }
59  
60 # sub Write { # @_ = ( command => $cmd, wait_status => $wait_status, brutal => 1/0 )
61 # return 0; # status true/false
62 # }
63  
64 # sub Read { # @_ = ( read_length => $read_length, brutal => 1/0 )
65 # return 0; # result
66 # }
67  
68 # now comes RS232-specific stuff
69  
70 # Initialization is handled by default by the bus (see e.g. Bus::RS232).
71 # In some cases when this is not possible it can be done by a derived connection class.
72  
73 1;
74  
75  
76 1;
77  
78 __END__