| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
######################################################################################### |
|
2
|
|
|
|
|
|
|
# Package HiPi::Device::OneWire |
|
3
|
|
|
|
|
|
|
# Description : 1-Wire Device |
|
4
|
|
|
|
|
|
|
# Copyright : Copyright (c) 2013-2017 Mark Dootson |
|
5
|
|
|
|
|
|
|
# License : This is free software; you can redistribute it and/or modify it under |
|
6
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
7
|
|
|
|
|
|
|
######################################################################################### |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package HiPi::Device::OneWire; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
######################################################################################### |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1136
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
73
|
|
|
16
|
1
|
|
|
1
|
|
7
|
use HiPi; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use parent qw( HiPi::Device ); |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
7
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION ='0.81'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our %idmap = ( |
|
22
|
|
|
|
|
|
|
'01' => [ '2401/11', 'silicon serial number'], |
|
23
|
|
|
|
|
|
|
'02' => [ '1425', 'multikey 1153bit secure'], |
|
24
|
|
|
|
|
|
|
'04' => [ '2404', 'econoram time chip'], |
|
25
|
|
|
|
|
|
|
'05' => [ '2405', 'Addressable Switch'], |
|
26
|
|
|
|
|
|
|
'06' => [ '', '4k memory ibutton'], |
|
27
|
|
|
|
|
|
|
'08' => [ '', '1k memory ibutton'], |
|
28
|
|
|
|
|
|
|
'09' => [ '2502', '1k add-only memory'], |
|
29
|
|
|
|
|
|
|
'0A' => [ '', '16k memory ibutton'], |
|
30
|
|
|
|
|
|
|
'0B' => [ '2505', '16k add-only memory'], |
|
31
|
|
|
|
|
|
|
'0C' => [ '', '64k memory ibutton'], |
|
32
|
|
|
|
|
|
|
'0F' => [ '2506', '64k add-only memory'], |
|
33
|
|
|
|
|
|
|
'10' => [ '18S20', 'high precision digital thermometer'], |
|
34
|
|
|
|
|
|
|
'12' => [ '2406/2407', 'dual addressable switch plus 1k memory'], |
|
35
|
|
|
|
|
|
|
'14' => [ '2430A', '256 eeprom'], |
|
36
|
|
|
|
|
|
|
'1A' => [ '', '4k Monetary'], |
|
37
|
|
|
|
|
|
|
'1B' => [ '2436', 'battery id/monitor chip'], |
|
38
|
|
|
|
|
|
|
'1C' => [ '28E04-100', '4k EEPROM with PIO'], |
|
39
|
|
|
|
|
|
|
'1D' => [ '2423', '4k ram with counter'], |
|
40
|
|
|
|
|
|
|
'1F' => [ '2409', 'microlan coupler'], |
|
41
|
|
|
|
|
|
|
'20' => [ '2450', 'quad a/d converter'], |
|
42
|
|
|
|
|
|
|
'21' => [ '', 'Thermachron'], |
|
43
|
|
|
|
|
|
|
'22' => [ '1822', 'Econo Digital Thermometer'], |
|
44
|
|
|
|
|
|
|
'23' => [ '2433', '4k eeprom'], |
|
45
|
|
|
|
|
|
|
'24' => [ '2415', 'time chip'], |
|
46
|
|
|
|
|
|
|
'26' => [ '2438', 'smart battery monitor'], |
|
47
|
|
|
|
|
|
|
'27' => [ '2417', 'time chip with interrupt'], |
|
48
|
|
|
|
|
|
|
'28' => [ '18B20', 'programmable resolution digital thermometer'], |
|
49
|
|
|
|
|
|
|
'29' => [ '2408', '8-channel addressable switch'], |
|
50
|
|
|
|
|
|
|
'2C' => [ '2890', 'digital potentiometer'], |
|
51
|
|
|
|
|
|
|
'2D' => [ '2431', '1k eeprom'], |
|
52
|
|
|
|
|
|
|
'2E' => [ '2770', 'battery monitor and charge controller'], |
|
53
|
|
|
|
|
|
|
'30' => [ '2760/61/62', 'high-precision li+ battery monitor'], |
|
54
|
|
|
|
|
|
|
'31' => [ '2720', 'efficient addressable single-cell rechargable lithium protection ic'], |
|
55
|
|
|
|
|
|
|
'33' => [ '2432', '1k protected eeprom with SHA-1'], |
|
56
|
|
|
|
|
|
|
'36' => [ '2740', 'high precision coulomb counter'], |
|
57
|
|
|
|
|
|
|
'37' => [ '', 'Password protected 32k eeprom'], |
|
58
|
|
|
|
|
|
|
'3A' => [ '2413', 'dual channel addressable switch'], |
|
59
|
|
|
|
|
|
|
'41' => [ '2422', 'Temperature Logger 8k mem'], |
|
60
|
|
|
|
|
|
|
'51' => [ '2751', 'multichemistry battery fuel gauge'], |
|
61
|
|
|
|
|
|
|
'81' => [ '', 'Serial ID Button'], |
|
62
|
|
|
|
|
|
|
'84' => [ '2404S', 'dual port plus time'], |
|
63
|
|
|
|
|
|
|
'89' => [ '2502-E48/UNW', '48 bit node address chip'], |
|
64
|
|
|
|
|
|
|
'8B' => [ '2505-UNW', '16k add-only'], |
|
65
|
|
|
|
|
|
|
'8F' => [ '2506-UNW', '64k add-only uniqueware'], |
|
66
|
|
|
|
|
|
|
'FF' => [ 'LCD', 'LCD (Swart)'], |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub get_required_module_options { |
|
70
|
0
|
|
|
0
|
0
|
|
my $moduleoptions = [ |
|
71
|
|
|
|
|
|
|
[ qw( w1_gpio wire ) ], # w1_therm is loaded on demand |
|
72
|
|
|
|
|
|
|
]; |
|
73
|
0
|
|
|
|
|
|
return $moduleoptions; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub list_slaves { |
|
77
|
0
|
|
|
0
|
0
|
|
my( $class ) = @_; |
|
78
|
0
|
|
|
|
|
|
my @rlist = (); |
|
79
|
0
|
|
|
|
|
|
my $slist = qx(/bin/cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves); |
|
80
|
0
|
0
|
|
|
|
|
if( $? ) { |
|
81
|
0
|
|
|
|
|
|
return @rlist; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
0
|
|
|
|
|
|
my @slaves = split(/\n/, $slist); |
|
84
|
0
|
|
|
|
|
|
for my $id ( @slaves ) { |
|
85
|
0
|
|
|
|
|
|
my ( $family, $discard ) = split(/-/, $id); |
|
86
|
0
|
0
|
|
|
|
|
$family = '0' . $family if length($family) == 1; |
|
87
|
0
|
|
|
|
|
|
my ($name, $desc) = ('',''); |
|
88
|
0
|
0
|
|
|
|
|
if(exists($idmap{$family})) { |
|
89
|
0
|
|
|
|
|
|
$name = $idmap{$family}->[0]; |
|
90
|
0
|
|
|
|
|
|
$desc = $idmap{$family}->[1]; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
0
|
|
|
|
|
|
push(@rlist, { id => $id, family => $family, name => $name, description => $desc} ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
0
|
|
|
|
|
|
return @rlist; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub read_data { |
|
98
|
0
|
|
|
0
|
0
|
|
my( $class, $id ) = @_; |
|
99
|
|
|
|
|
|
|
# return data & or errors |
|
100
|
0
|
|
|
|
|
|
my $data = qx(/bin/cat /sys/bus/w1/devices/$id/w1_slave); |
|
101
|
0
|
|
|
|
|
|
chomp($data); |
|
102
|
0
|
|
|
|
|
|
return $data; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub id_exists { |
|
106
|
0
|
|
|
0
|
0
|
|
my( $class, $id) = @_; |
|
107
|
0
|
|
|
|
|
|
my $slist = qx(/bin/cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves); |
|
108
|
0
|
0
|
0
|
|
|
|
return ( $slist =~ /\Q$id\E/ && -e qq(/sys/bus/w1/devices/$id/w1_slave) ) ? 1 : 0; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |