don't die if we can't read tag
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 27 Jul 2010 11:52:02 +0000 (13:52 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 27 Jul 2010 11:52:02 +0000 (13:52 +0200)
lib/RFID/Serial.pm

index e9435f6..80a78d7 100644 (file)
@@ -91,7 +91,15 @@ sub scan {
 
        my $visible;
        # FIXME this is naive implementation which just discards other tags
-       $visible->{$_} = $self->read_blocks( $_ )->{$_} foreach @tags;
+       foreach my $tag ( @tags ) {
+               my $blocks = $self->read_blocks( $tag );
+               if ( ! $blocks ) {
+                       warn "ERROR: can't read tag $tag\n";
+                       delete $visible->{$tag};
+               } else {
+                       $visible->{$tag} = $blocks->{$tag};
+               }
+       }
 
        return $visible;
 }