File Coverage

blib/lib/RFID/Matrics/Reader/Serial.pm
Criterion Covered Total %
statement 33 48 68.7
branch 0 4 0.0
condition 0 7 0.0
subroutine 11 12 91.6
pod 1 1 100.0
total 45 72 62.5


line stmt bran cond sub pod time code
1             package RFID::Matrics::Reader::Serial;
2 2     2   39155 use RFID::Matrics::Reader; $VERSION=$RFID::Matrics::Reader::VERSION;
  2         5  
  2         124  
3 2     2   1724 use RFID::Reader::Serial;
  2         2612  
  2         62  
4 2     2   15 use Exporter;
  2         5  
  2         179  
5             @ISA = qw(RFID::Reader::Serial RFID::Matrics::Reader Exporter);
6             @EXPORT_OK = @RFID::Matrics::Reader::EXPORT_OK;
7             %EXPORT_TAGS = %RFID::Matrics::Reader::EXPORT_TAGS;
8            
9             # Written by Scott Gifford
10             # Copyright (C) 2004 The Regents of the University of Michigan.
11             # See the file LICENSE included with the distribution for license
12             # information.
13            
14             =head1 NAME
15            
16             RFID::Matrics::Reader::Serial - Implement L over a serial link
17            
18             =head1 SYNOPSIS
19            
20             This class takes a serial port object and implements the Matrics RFID
21             protocol over it. This object is based on
22             L, which should be
23             consulted for additional information.
24            
25             An example:
26            
27             use Win32::Serialport;
28             use RFID::Matrics::Reader::Serial;
29            
30             $com = Win32::SerialPort->new($opt{c})
31             or die "Couldn't open COM port '$opt{c}': $^E\n";
32            
33             my $reader =
34             RFID::Matrics::Reader::Serial->new(Port => $com,
35             Node => 4,
36             Antenna => 1)
37             or die "Couldn't create reader object";
38            
39             =head1 DESCRIPTION
40            
41             This class is built on top of
42             L, and uses
43             L to implement the
44             underlying setup, reading, and writing functions.
45            
46             =cut
47            
48 2     2   11 use RFID::Matrics::Reader qw(:ant);
  2         20  
  2         356  
49 2     2   12 use Carp;
  2         4  
  2         128  
50            
51 2     2   11 use constant BAUDRATE => 230400;
  2         4  
  2         116  
52 2     2   11 use constant DATABITS => 8;
  2         4  
  2         99  
53 2     2   10 use constant STOPBITS => 1;
  2         4  
  2         89  
54 2     2   14 use constant PARITY => 'none';
  2         5  
  2         91  
55 2     2   9 use constant HANDSHAKE => 'none';
  2         3  
  2         89  
56 2     2   9 use constant DEFAULT_TIMEOUT => 2000; #ms
  2         1  
  2         585  
57            
58             =head2 Constructor
59            
60             =head3 new
61            
62             This creates a new
63             L object.
64             All parameters are simply sent along to either
65             L
66             or L.
67            
68             =cut
69            
70             sub new
71             {
72 0     0 1   my $class = shift;
73 0           my(%p)=@_;
74            
75 0           my $self = {};
76            
77 0 0 0       $self->{com} = $p{Port}||$p{comport}
78             or croak __PACKAGE__."::new requires argument 'Port'\n";
79 0   0       $self->{timeout} = $p{Timeout}||$p{timeout}||DEFAULT_TIMEOUT;
80            
81 0           $self->{databits}=DATABITS;
82 0           $self->{stopbits}=STOPBITS;
83 0           $self->{parity}=PARITY;
84 0           $self->{handshake}=HANDSHAKE;
85 0   0       $self->{baudrate}=$p{Baudrate}||$p{baudrate}||BAUDRATE;
86            
87 0           bless $self,$class;
88            
89             # Initialize everything.
90 0           foreach my $parent (@ISA)
91             {
92 0 0         if (my $init = $parent->can('_init'))
93             {
94 0           $init->($self,%p);
95             }
96             }
97            
98 0           $self;
99             }
100            
101             =head1 SEE ALSO
102            
103             L, L,
104             L, L, L,
105             L.
106            
107             =head1 AUTHOR
108            
109             Scott Gifford ,
110            
111             Copyright (C) 2004 The Regents of the University of Michigan.
112            
113             See the file LICENSE included with the distribution for license
114             information.
115            
116             =cut
117            
118             1;