File Coverage

blib/lib/Device/DSE/Q1573.pm
Criterion Covered Total %
statement 31 35 88.5
branch n/a
condition 1 3 33.3
subroutine 9 10 90.0
pod 2 2 100.0
total 43 50 86.0


line stmt bran cond sub pod time code
1             package Device::DSE::Q1573;
2              
3 1     1   43186 use DynaLoader;
  1         2  
  1         34  
4              
5              
6 1     1   1178 use Device::SerialPort qw(:STAT);
  1         43241  
  1         270  
7 1     1   10 use POSIX qw(:termios_h);
  1         7  
  1         7  
8 1     1   459 use Fcntl;
  1         3  
  1         357  
9              
10 1     1   6 use strict;
  1         1  
  1         47  
11              
12              
13             BEGIN {
14 1     1   5 use Exporter ();
  1         1  
  1         21  
15 1     1   6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $PortObj);
  1         1  
  1         147  
16 1     1   3 $VERSION = '0.7';
17 1         22 @ISA = qw(Exporter DynaLoader);
18 1         1 @EXPORT = qw();
19 1         2 @EXPORT_OK = qw();
20 1         2 %EXPORT_TAGS = ();
21 1         601 bootstrap Device::DSE::Q1573, $VERSION;
22             }
23              
24              
25              
26             #################### subroutine header begin ####################
27              
28             # Create Instance
29              
30             #################### subroutine header end ####################
31              
32              
33             sub new
34             {
35 1     1 1 14 my ($class, $serialport) = @_;
36              
37            
38            
39            
40 1   33     9 my $self = bless ({}, ref ($class) || $class);
41            
42 1         10 $self->{serialport} = $serialport;
43              
44 1         4 return $self;
45             }
46             #################### subroutine header begin ####################
47              
48             #Read meter
49              
50             #################### subroutine header end ####################
51              
52             sub rawread {
53            
54 0     0 1   my $self = shift;
55            
56 0           my $readval;
57 0           terminal($self->{serialport}, $readval);
58 0           return $readval;
59             }
60              
61              
62              
63              
64             #################### main pod documentation begin ###################
65              
66              
67              
68             =head1 NAME
69              
70             Device::DSE::Q1573 - Read data from DSE Q1573 Digital Multimeter
71              
72             =head1 SYNOPSIS
73              
74             use Device::DSE::Q1573;
75             my $meter = Device::DSE::Q1573->new("/dev/ttyS0");
76             my $reading = $meter->read();
77             my $reading = $meter->rawread();
78              
79              
80             =head1 DESCRIPTION
81              
82             Sets up a connection to a DSE Q1573 or Metex ME-22
83             Digital Multimeter, and allows you to read measurements
84             from it. The data return is 14 bytes of the format:
85              
86             Type:Data:Units
87             eg reading when temperature is selected on the meter
88             will return
89              
90             "TE 0019 C "
91              
92             =head1 USAGE
93              
94             =head2 new(serialport)
95              
96             Usage : my $meter=Device::DSE::Q1573->new("/dev/ttyS0")
97             Purpose : Opens the meter on the specified serial port
98             Returns : object of type Device::DSE::Q1573
99             Argument : serial port
100            
101             =head2 rawread();
102              
103             Usage : my $meter->rawread()
104             Purpose : Returns the 14 byte string from the meter.
105              
106             =head2 read();
107              
108             Usage : my $meter->read()
109             Purpose : Returns a hash of values for the reading:
110            
111             {
112             setting => setting eg TE for temperature
113             value => value read eg 14
114             units => units read eg C for celsius
115            
116             }
117            
118            
119             =head1 EXAMPLE
120              
121             use Device::DSE::Q1573;
122              
123             my $meter = Device::DSE::Q1573->new( "/dev/ttyS0" );
124              
125             while(1) {
126             my $data = $meter->read();
127             print $data->{value} . "\n";
128             sleep(1);
129             }
130              
131              
132             =head1 AUTHOR
133              
134             David Peters
135             CPAN ID: DAVIDP
136             davidp@electronf.com
137             http://www.electronf.com
138              
139             =head1 COPYRIGHT
140              
141             This program is free software; you can redistribute
142             it and/or modify it under the same terms as Perl itself.
143              
144             The full text of the license can be found in the
145             LICENSE file included with this module.
146              
147              
148             =head1 SEE ALSO
149              
150             perl(1).
151              
152             =cut
153              
154             #################### main pod documentation end ###################
155              
156              
157             1;
158              
159