| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Omega::DP41::Data::Current; |
|
2
|
1
|
|
|
1
|
|
35338
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
34
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
114
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use base 'Exporter'; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
265
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.3.4'; |
|
6
|
|
|
|
|
|
|
our @EXPORT = qw(serial_data); |
|
7
|
|
|
|
|
|
|
#################### |
|
8
|
|
|
|
|
|
|
### OS Dependant ### |
|
9
|
|
|
|
|
|
|
#################### |
|
10
|
|
|
|
|
|
|
BEGIN { |
|
11
|
1
|
|
|
1
|
|
3736
|
require autouse; |
|
12
|
1
|
50
|
|
|
|
881
|
autouse->import( |
|
13
|
|
|
|
|
|
|
$^O =~ /^win32/i ? "Win32::SerialPort" : "Device::SerialPort" |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
######################## |
|
17
|
|
|
|
|
|
|
### End OS Dependant ### |
|
18
|
|
|
|
|
|
|
######################## |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
DP41::Data::Current - Module for retrieving data from an Omega brand Thermacouple. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use DP41::Data::Current; |
|
27
|
|
|
|
|
|
|
$temp = serial_data(); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 REQUIRES |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Requires Device::SerialPort or Win32::SerialPort depending on platform. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Module for retrieving the current reading on a Omega DP41 Thermocouple. Module has been tested on Omega DP41-RTD only, unknown if it will work with other models. Requires Device::SerialPort or Win32::SerialPort depending on platform. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 AUTHOR/LICENSE |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Perl Module DP41::Data::Current, retrieves current reading from Omega DP41-RTD Thermocouple. |
|
40
|
|
|
|
|
|
|
Copyright (C) 2008-2009 Stanford University, Authored by Sam Kerr kerr@cpan.org |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
43
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
44
|
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or |
|
45
|
|
|
|
|
|
|
(at your option) any later version. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
48
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
49
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
50
|
|
|
|
|
|
|
GNU General Public License for more details. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
53
|
|
|
|
|
|
|
along with this program; if not, write to the Free Software |
|
54
|
|
|
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 Functions |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
One function is exported by default (serial_data). |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head3 serial_data |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$temp = serial_data(); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns the current reading from a DP41 Thermacouple. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 Changelog |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
04-06-09 - v0.3.4 Added PREREQ_PM => Device::SerialPort to makefile |
|
70
|
|
|
|
|
|
|
04-02-09 - v0.3.2 Modified to run on Win32 (experimental!) |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub serial_data{ |
|
76
|
0
|
|
|
0
|
1
|
|
my $current; |
|
77
|
0
|
|
|
|
|
|
my $device = "/dev/ttyS0"; |
|
78
|
0
|
|
|
|
|
|
my $serial = Device::SerialPort-> new($device, 1); |
|
79
|
0
|
0
|
|
|
|
|
die "Can't open serial port $serial: $^E\n" unless ($serial); |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$serial->user_msg(0); |
|
82
|
0
|
|
|
|
|
|
$serial->databits(7); |
|
83
|
0
|
|
|
|
|
|
$serial->baudrate(9600); |
|
84
|
0
|
|
|
|
|
|
$serial->parity("odd"); |
|
85
|
0
|
|
|
|
|
|
$serial->stopbits(1); |
|
86
|
0
|
|
|
|
|
|
$serial->handshake("none"); |
|
87
|
0
|
|
|
|
|
|
$serial->datatype('raw'); |
|
88
|
0
|
|
|
|
|
|
$serial->dtr_active('T'); |
|
89
|
0
|
|
|
|
|
|
$serial->stty_icrnl(0); |
|
90
|
0
|
|
|
|
|
|
$serial->write_settings; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
print $serial->write("*X01\r"); |
|
93
|
0
|
|
|
|
|
|
my $STALL_DEFAULT=5; |
|
94
|
0
|
|
|
|
|
|
my $timeout=$STALL_DEFAULT; |
|
95
|
0
|
|
|
|
|
|
$serial->read_char_time(0); |
|
96
|
0
|
|
|
|
|
|
$serial->read_const_time(1000); |
|
97
|
0
|
|
|
|
|
|
my $chars=0; |
|
98
|
0
|
|
|
|
|
|
my $buffer=""; |
|
99
|
0
|
|
|
|
|
|
my ($count,$saw)=$serial->read(255); |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
if ($count > 0) { |
|
102
|
0
|
|
|
|
|
|
$chars+=$count; |
|
103
|
0
|
|
|
|
|
|
$buffer.=$saw; |
|
104
|
0
|
|
|
|
|
|
$current = $buffer; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$current =~ s/^X......//g; |
|
108
|
0
|
|
|
|
|
|
$current =~ s/\.{1}//g; |
|
109
|
0
|
|
|
|
|
|
return $current; |
|
110
|
0
|
|
|
|
|
|
$serial->close(); |
|
111
|
|
|
|
|
|
|
} |