Merge branch 'master' into 3M-810
[Biblio-RFID.git] / lib / RFID / Biblio / Reader / 3M810.pm
index f26e9ab..421dd9b 100644 (file)
@@ -6,11 +6,11 @@ RFID::Biblio::Reader::3M810 - support for 3M 810 RFID reader
 
 =head1 DESCRIPTION
 
-This module implement serial protocol (over USB/serial adapter) with 3M 810 RFID
-reader, often used in library applications.
+This module uses L<RFID::Biblio::Reader::Serial> over USB/serial adapter
+with 3M 810 RFID reader, often used in library applications.
 
-This is most complete implementation which supports full API defined
-in L<RFID::Biblio>. This include scanning for all tags in reader
+This is most mature implementation which supports full API defined
+in L<RFID::Biblio::Reader::API>. This include scanning for all tags in reader
 range, reading and writing of data, and AFI security manipulation.
 
 This implementation is developed using Portmon on Windows to capture serial traffic
@@ -19,12 +19,15 @@ L<http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx>
 Checksum for this reader is developed using help from C<selwyn>
 L<http://stackoverflow.com/questions/149617/how-could-i-guess-a-checksum-algorithm>
 
+More inforation about process of reverse engeeniring protocol with
+this reader is available at L<http://blog.rot13.org/rfid/>
+
 =cut
 
 use warnings;
 use strict;
 
-use base 'RFID::Biblio';
+use base 'RFID::Biblio::Reader::Serial';
 use RFID::Biblio;
 
 use Data::Dump qw(dump);
@@ -33,7 +36,6 @@ use Time::HiRes;
 use Digest::CRC;
 
 sub serial_settings {{
-       device    => "/dev/ttyUSB1", # FIXME comment out before shipping
        baudrate  => "19200",
        databits  => "8",
        parity    => "none",
@@ -72,10 +74,6 @@ sub checksum {
        pack('n', $crc->digest);
 }
 
-sub wait_device {
-       Time::HiRes::sleep 0.015;
-}
-
 sub cmd {
        my ( $hex, $description, $coderef ) = @_;
        my $bytes = hex2bytes($hex);
@@ -89,26 +87,15 @@ sub cmd {
        warn ">> ", as_hex( $bytes ), "\t\t[$description]\n";
        $port->write( $bytes );
 
-       wait_device;
-
        my $r_len = $port->read(3);
 
        while ( length($r_len) < 3 ) {
-               wait_device;
                $r_len = $port->read( 3 - length($r_len) );
        }
 
-       wait_device;
-
        my $len = ord( substr($r_len,2,1) );
        my $data = $port->read( $len );
 
-       while ( length($data) < $len ) {
-               warn "# short read ", length($data), " < $len\n";
-               wait_device;
-               $data .= $port->read( $len - length($data) );
-       }
-
        warn "<< ", as_hex($r_len,$data),
                ' | ',
                substr($data,-2,2) eq checksum(substr($r_len,1).substr($data,0,-2)) ? 'OK' : 'ERROR',
@@ -148,12 +135,6 @@ cmd(
 )});
 }
 
-=head2 inventory
-
-  my @tags = inventory;
-
-=cut
-
 sub inventory {
 
        my @tags;
@@ -320,3 +301,9 @@ sub write_afi {
 }
 
 1
+
+__END__
+
+=head1 SEE ALSO
+
+L<RFID::Biblio::Reader::API>