6 use Device::SerialPort qw(:STAT);
7 use Data::Dump qw(dump);
11 RFID::Serial - support serial RFID devices
15 our $VERSION = '0.01';
20 our @EXPORT = qw( hex2bytes as_hex );
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);
117 Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
121 Please report any bugs or feature requests to C<bug-rfid-serial at rt.cpan.org>, or through
122 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RFID-Serial>. I will be notified, and then you'll
123 automatically be notified of progress on your bug as I make changes.
130 You can find documentation for this module with the perldoc command.
135 You can also look for information at:
139 =item * RT: CPAN's request tracker
141 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=RFID-Serial>
143 =item * AnnoCPAN: Annotated CPAN documentation
145 L<http://annocpan.org/dist/RFID-Serial>
149 L<http://cpanratings.perl.org/d/RFID-Serial>
153 L<http://search.cpan.org/dist/RFID-Serial/>
158 =head1 ACKNOWLEDGEMENTS
161 =head1 LICENSE AND COPYRIGHT
163 Copyright 2010 Dobrica Pavlinusic.
165 This program is free software; you can redistribute it and/or modify
166 it under the terms of the GNU General Public License as published by
167 the Free Software Foundation; version 2 dated June, 1991 or at your option
170 This program is distributed in the hope that it will be useful,
171 but WITHOUT ANY WARRANTY; without even the implied warranty of
172 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
173 GNU General Public License for more details.
175 A copy of the GNU General Public License is available in the source tree;
176 if not, write to the Free Software Foundation, Inc.,
177 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
182 1; # End of RFID::Serial