line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Biblio::RFID; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
39009
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
194
|
|
4
|
5
|
|
|
5
|
|
45
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
164
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
26
|
use base 'Exporter'; |
|
5
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
795
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( hex2bytes as_hex hex_tag $debug ); |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
1002
|
use Data::Dump qw(dump); |
|
5
|
|
|
|
|
10174
|
|
|
5
|
|
|
|
|
2703
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Biblio::RFID - perl tools to use different RFID readers for library use |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $debug = 0; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Main idea is to develop simple API to reader, and than provide useful |
25
|
|
|
|
|
|
|
abstractions on top of it to quickly write applications to respond on |
26
|
|
|
|
|
|
|
tags which come in range of RFID reader using L. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Writing support for new RFID readers should be easy. |
29
|
|
|
|
|
|
|
L provides documentation on writing support |
30
|
|
|
|
|
|
|
for different readers. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Currently, two serial RFID readers based on L |
33
|
|
|
|
|
|
|
are implemented: |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=over 4 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item * |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
L |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item * |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
L |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=back |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
There is also simple read-only reader using shell commands in |
48
|
|
|
|
|
|
|
L. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
For implementing application take a look at L |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
C is example of such application. It's local |
53
|
|
|
|
|
|
|
interface to RFID reader and JSONP REST server. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
C is jQuery based JavaScript code which can be inserted |
56
|
|
|
|
|
|
|
in Koha Library System to provide overlay with tags in range and |
57
|
|
|
|
|
|
|
check-in/check-out form-fill functionality. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Applications can use L which is some kind of |
60
|
|
|
|
|
|
|
semi-standard 3M layout or blocks on RFID tags. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=for readme stop |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 EXPORT |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Formatting functions are exported |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 hex2bytes |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $bytes = hex2bytes($hex); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub hex2bytes { |
75
|
0
|
|
0
|
0
|
1
|
|
my $str = shift || die "no str?"; |
76
|
0
|
|
|
|
|
|
my $b = $str; |
77
|
0
|
|
|
|
|
|
$b =~ s/\s+//g; |
78
|
0
|
|
|
|
|
|
$b =~ s/(..)/\\x$1/g; |
79
|
0
|
|
|
|
|
|
$b = "\"$b\""; |
80
|
0
|
|
|
|
|
|
my $bytes = eval $b; |
81
|
0
|
0
|
|
|
|
|
die $@ if $@; |
82
|
0
|
0
|
|
|
|
|
warn "## str2bytes( $str ) => $b => ",as_hex($bytes) if $debug; |
83
|
0
|
|
|
|
|
|
return $bytes; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 as_hex |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
print as_hex( $bytes ); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub as_hex { |
93
|
0
|
|
|
0
|
1
|
|
my @out; |
94
|
0
|
|
|
|
|
|
foreach my $str ( @_ ) { |
95
|
0
|
|
|
|
|
|
my $hex = uc unpack( 'H*', $str ); |
96
|
0
|
0
|
|
|
|
|
$hex =~ s/(..)/$1 /g if length( $str ) > 2; |
97
|
0
|
|
|
|
|
|
$hex =~ s/\s+$//; |
98
|
0
|
|
|
|
|
|
push @out, $hex; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
return join(' | ', @out); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 hex_tag |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
print hex_tag $8bytes; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
0
|
1
|
|
sub hex_tag { uc(unpack('H16', shift)) } |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 WARN |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
We are installing L handler to controll debug output |
114
|
|
|
|
|
|
|
based on C<$Biblio::RFID::debug> level |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
BEGIN { |
119
|
|
|
|
|
|
|
$SIG{'__WARN__'} = sub { |
120
|
4
|
|
|
|
|
176
|
my $msg = join(' ', @_); |
121
|
4
|
50
|
|
|
|
28
|
if ( $msg =~ m/^(#+)/ ) { |
122
|
4
|
|
|
|
|
13
|
my $l = length $1; |
123
|
4
|
50
|
|
|
|
24
|
return if $l > $debug; |
124
|
|
|
|
|
|
|
} |
125
|
0
|
|
|
|
|
|
warn join(' ', @_); |
126
|
|
|
|
|
|
|
} |
127
|
5
|
|
|
5
|
|
364
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=for readme continue |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 HARDWARE SUPPORT |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 3M 810 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 CPR-M02 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 librfid |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Dobrica Pavlinusic, C<< >> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 BUGS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
155
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
156
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SUPPORT |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
perldoc Biblio::RFID |
166
|
|
|
|
|
|
|
perldoc Biblio::RFID::Reader |
167
|
|
|
|
|
|
|
perldoc Biblio::RFID::Reader::API |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
You can also look for information at: |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=over 4 |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
L |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * CPAN Ratings |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * Search CPAN |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
L |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=back |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Copyright 2010 Dobrica Pavlinusic. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
201
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
202
|
|
|
|
|
|
|
the Free Software Foundation; version 2 dated June, 1991 or at your option |
203
|
|
|
|
|
|
|
any later version. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
206
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
207
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
208
|
|
|
|
|
|
|
GNU General Public License for more details. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
A copy of the GNU General Public License is available in the source tree; |
211
|
|
|
|
|
|
|
if not, write to the Free Software Foundation, Inc., |
212
|
|
|
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=cut |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; # End of Biblio::RFID |