projects
/
Biblio-RFID.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ec0e32f
)
remove all wait_device since we are using timeouts
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 9 Aug 2010 17:08:49 +0000
(19:08 +0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 9 Aug 2010 17:08:49 +0000
(19:08 +0200)
lib/RFID/Biblio/Reader/3M810.pm
patch
|
blob
|
history
diff --git
a/lib/RFID/Biblio/Reader/3M810.pm
b/lib/RFID/Biblio/Reader/3M810.pm
index
9679e68
..
421dd9b
100644
(file)
--- a/
lib/RFID/Biblio/Reader/3M810.pm
+++ b/
lib/RFID/Biblio/Reader/3M810.pm
@@
-74,10
+74,6
@@
sub checksum {
pack('n', $crc->digest);
}
pack('n', $crc->digest);
}
-sub wait_device {
- Time::HiRes::sleep 0.015;
-}
-
sub cmd {
my ( $hex, $description, $coderef ) = @_;
my $bytes = hex2bytes($hex);
sub cmd {
my ( $hex, $description, $coderef ) = @_;
my $bytes = hex2bytes($hex);
@@
-91,26
+87,15
@@
sub cmd {
warn ">> ", as_hex( $bytes ), "\t\t[$description]\n";
$port->write( $bytes );
warn ">> ", as_hex( $bytes ), "\t\t[$description]\n";
$port->write( $bytes );
- wait_device;
-
my $r_len = $port->read(3);
while ( length($r_len) < 3 ) {
my $r_len = $port->read(3);
while ( length($r_len) < 3 ) {
- wait_device;
$r_len = $port->read( 3 - length($r_len) );
}
$r_len = $port->read( 3 - length($r_len) );
}
- wait_device;
-
my $len = ord( substr($r_len,2,1) );
my $data = $port->read( $len );
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',
warn "<< ", as_hex($r_len,$data),
' | ',
substr($data,-2,2) eq checksum(substr($r_len,1).substr($data,0,-2)) ? 'OK' : 'ERROR',