line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RFID::Alien::Reader::Serial;
|
2
|
2
|
|
|
2
|
|
33501
|
use RFID::Alien::Reader; $VERSION=$RFID::Alien::Reader::VERSION;
|
|
2
|
|
|
|
|
1431
|
|
|
2
|
|
|
|
|
391
|
|
3
|
2
|
|
|
2
|
|
2497
|
use RFID::Reader::Serial;
|
|
2
|
|
|
|
|
4621
|
|
|
2
|
|
|
|
|
106
|
|
4
|
|
|
|
|
|
|
@ISA = qw(RFID::Reader::Serial RFID::Alien::Reader);
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Written by Scott Gifford
|
7
|
|
|
|
|
|
|
# Copyright (C) 2004-2006 The Regents of the University of Michigan.
|
8
|
|
|
|
|
|
|
# See the file LICENSE included with the distribution for license
|
9
|
|
|
|
|
|
|
# information.
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
RFID::Alien::Reader::Serial - Implement L over a serial link
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This class takes a serial port object and implements the Alien RFID
|
18
|
|
|
|
|
|
|
protocol over it. It is based on L, and it takes the same parameters as L. All other parameters are passed along to the
|
19
|
|
|
|
|
|
|
L
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
An example:
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Win32::Serialport;
|
24
|
|
|
|
|
|
|
use RFID::Alien::Reader::Serial;
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$com = Win32::SerialPort->new('COM1')
|
27
|
|
|
|
|
|
|
or die "Couldn't open COM port 'COM1': $^E\n";
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $reader =
|
30
|
|
|
|
|
|
|
RFID::Alien::Reader::Serial->new(Port => $com,
|
31
|
|
|
|
|
|
|
AntennaSequence => [0,1,2,3])
|
32
|
|
|
|
|
|
|
or die "Couldn't create reader object\n";
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$reader->set(PersistTime => 0,
|
35
|
|
|
|
|
|
|
AcquireMode => 'Inventory') == 0
|
36
|
|
|
|
|
|
|
or die "Couldn't set reader properties\n";
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my @tags = $reader->readtags();
|
39
|
|
|
|
|
|
|
foreach my $tag (@tags)
|
40
|
|
|
|
|
|
|
{
|
41
|
|
|
|
|
|
|
print "I see tag ",$tag->id,"\n";
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This class is built on top of
|
47
|
|
|
|
|
|
|
L, and
|
48
|
|
|
|
|
|
|
L.
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut
|
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
2
|
|
12
|
use constant BAUDRATE => 115200;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
98
|
|
53
|
2
|
|
|
2
|
|
20
|
use constant DATABITS => 8;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
54
|
2
|
|
|
2
|
|
9
|
use constant STOPBITS => 1;
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
73
|
|
55
|
2
|
|
|
2
|
|
41
|
use constant PARITY => 'none';
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
75
|
|
56
|
2
|
|
|
2
|
|
9
|
use constant HANDSHAKE => 'none';
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
57
|
2
|
|
|
2
|
|
17
|
use constant DEFAULT_TIMEOUT => 30; # seconds
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
655
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 Constructor
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head3 new
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Creates a new object. This constructor accepts all arguments to the
|
64
|
|
|
|
|
|
|
constructors for L and
|
65
|
|
|
|
|
|
|
L, and passes them along to
|
66
|
|
|
|
|
|
|
both constructors. Any other settings are intrepeted as parameters to
|
67
|
|
|
|
|
|
|
the L method.
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub new
|
72
|
|
|
|
|
|
|
{
|
73
|
0
|
|
|
0
|
1
|
|
my $class = shift;
|
74
|
0
|
|
|
|
|
|
my(%p)=@_;
|
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $self = {};
|
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
$self->{com} = $p{Port}
|
79
|
|
|
|
|
|
|
or die __PACKAGE__."::new requires argument 'Port'\n";
|
80
|
0
|
|
|
|
|
|
delete $p{Port};
|
81
|
0
|
|
0
|
|
|
|
$self->{timeout} = $p{Timeout}||$p{timeout}||DEFAULT_TIMEOUT;
|
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$self->{databits}=DATABITS;
|
84
|
0
|
|
|
|
|
|
$self->{stopbits}=STOPBITS;
|
85
|
0
|
|
|
|
|
|
$self->{parity}=PARITY;
|
86
|
0
|
|
|
|
|
|
$self->{handshake}=HANDSHAKE;
|
87
|
0
|
|
0
|
|
|
|
$self->{baudrate}=$p{Baudrate}||$p{baudrate}||BAUDRATE;
|
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
bless $self,$class;
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Initialize everything.
|
92
|
0
|
|
|
|
|
|
foreach my $parent (__PACKAGE__,@ISA)
|
93
|
|
|
|
|
|
|
{
|
94
|
0
|
0
|
|
|
|
|
if (my $init = $parent->can('_init'))
|
95
|
|
|
|
|
|
|
{
|
96
|
0
|
|
|
|
|
|
$init->($self,%p);
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Now clear out any data waiting on the serial port.
|
101
|
0
|
|
|
|
|
|
$self->{com}->purge_all;
|
102
|
0
|
|
|
|
|
|
$self->_writebytes("\x0d\x0a");
|
103
|
0
|
|
|
|
|
|
my($rb,$data);
|
104
|
|
|
|
|
|
|
do
|
105
|
0
|
|
|
|
|
|
{
|
106
|
0
|
|
|
|
|
|
$self->{com}->read_const_time(250);
|
107
|
0
|
|
|
|
|
|
($rb,$data)=$self->{com}->read(4096);
|
108
|
0
|
|
|
|
|
|
$self->debug("Discarding $rb bytes of junk data: '$data'\n");
|
109
|
|
|
|
|
|
|
} while ($rb);
|
110
|
0
|
|
|
|
|
|
$self->{com}->purge_all;
|
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
$self;
|
113
|
|
|
|
|
|
|
}
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SEE ALSO
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L, L,
|
119
|
|
|
|
|
|
|
L, L.
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Scott Gifford Egifford@umich.eduE, Esgifford@suspectclass.comE
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Copyright (C) 2004-2006 The Regents of the University of Michigan.
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
See the file LICENSE included with the distribution for license
|
128
|
|
|
|
|
|
|
information.
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1;
|