rename module to Biblio::RFID
[Biblio-RFID.git] / lib / RFID / Biblio / Reader / Serial.pm
index 6525913..39282f0 100644 (file)
@@ -1,4 +1,4 @@
-package RFID::Biblio::Reader::Serial;
+package Biblio::RFID::Reader::Serial;
 
 use warnings;
 use strict;
@@ -8,7 +8,7 @@ use Data::Dump qw(dump);
 
 =head1 NAME
 
-RFID::Biblio::Reader::Serial - base class for serial RFID readers
+Biblio::RFID::Reader::Serial - base class for serial RFID readers
 
 =head1 METHODS
 
@@ -23,7 +23,7 @@ sub new {
        my $self = {@_};
        bless $self, $class;
 
-       $self->port && $self->init && return $self;
+       $self->port && return $self;
 }
 
 
@@ -53,13 +53,21 @@ sub port {
                next if $serial_device->{$device};
 
                if ( my $port = Device::SerialPort->new($device) ) {
+
                        foreach my $opt ( qw/handshake baudrate databits parity stopbits/ ) {
                                $port->$opt( $settings->{$opt} );
                        }
-                       warn "found ", ref($self), " $device settings ",dump $settings;
+
                        $self->{port} = $port;
-                       $serial_device->{$device} = $port;
-                       last;
+
+                       warn "# probe by init $device ",ref($self);
+                       if ( $self->init ) {
+                               warn "init OK ", ref($self), " $device settings ",dump $settings;
+                               $serial_device->{$device} = $port;
+                               last;
+                       } else {
+                               $self->{port} = 0;
+                       }
                }
        }
 
@@ -73,9 +81,9 @@ __END__
 
 =head1 SEE ALSO
 
-L<RFID::Biblio::Reader::3M810>
+L<Biblio::RFID::Reader::3M810>
 
-L<RFID::Biblio::Reader::CPRM01>
+L<Biblio::RFID::Reader::CPRM01>
 
-L<RFID::Biblio::Reader::API>
+L<Biblio::RFID::Reader::API>