7 our @EXPORT = qw( hex2bytes as_hex hex_tag );
9 use Device::SerialPort qw(:STAT);
10 use Data::Dump qw(dump);
14 RFID::Serial - support serial RFID devices
18 our $VERSION = '0.01';
25 This module tries to support USB serial RFID readers wsing simple API
26 which is sutable for direct mapping to REST JSONP service.
28 Perhaps a little code snippet.
32 my $rfid = RFID::Serial->new(
33 device => '/dev/ttyUSB0', # with fallback to RFID_DEVICE
36 =head1 SUBROUTINES/METHODS
57 return $self->{port} if defined $self->{port};
59 my $settings = $self->serial_settings;
60 $settings->{device} ||= $ENV{RFID_DEVICE};
61 warn "# settings ",dump $settings;
63 $self->{port} = Device::SerialPort->new( $settings->{device} )
64 || die "can't open serial port: $!\n";
66 $self->{port}->$_( $settings->{$_} )
67 foreach ( qw/handshake baudrate databits parity stopbits/ );
77 Formatting functions are exported
81 my $bytes = hex2bytes($hex);
86 my $str = shift || die "no str?";
93 warn "## str2bytes( $str ) => $b => ",as_hex($bytes) if $debug;
99 print as_hex( $bytes );
105 foreach my $str ( @_ ) {
106 my $hex = uc unpack( 'H*', $str );
107 $hex =~ s/(..)/$1 /g if length( $str ) > 2;
111 return join(' | ', @out);
116 print hex_tag $bytes;
120 sub hex_tag { uc(unpack('H16', shift)) }
125 Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
129 Please report any bugs or feature requests to C<bug-rfid-serial at rt.cpan.org>, or through
130 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RFID-Serial>. I will be notified, and then you'll
131 automatically be notified of progress on your bug as I make changes.
138 You can find documentation for this module with the perldoc command.
143 You can also look for information at:
147 =item * RT: CPAN's request tracker
149 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=RFID-Serial>
151 =item * AnnoCPAN: Annotated CPAN documentation
153 L<http://annocpan.org/dist/RFID-Serial>
157 L<http://cpanratings.perl.org/d/RFID-Serial>
161 L<http://search.cpan.org/dist/RFID-Serial/>
166 =head1 ACKNOWLEDGEMENTS
169 =head1 LICENSE AND COPYRIGHT
171 Copyright 2010 Dobrica Pavlinusic.
173 This program is free software; you can redistribute it and/or modify
174 it under the terms of the GNU General Public License as published by
175 the Free Software Foundation; version 2 dated June, 1991 or at your option
178 This program is distributed in the hope that it will be useful,
179 but WITHOUT ANY WARRANTY; without even the implied warranty of
180 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181 GNU General Public License for more details.
183 A copy of the GNU General Public License is available in the source tree;
184 if not, write to the Free Software Foundation, Inc.,
185 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
190 1; # End of RFID::Serial