/[RFID]/cpr-m02.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /cpr-m02.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 82 by dpavlin, Fri Jul 9 23:10:05 2010 UTC revision 83 by dpavlin, Mon Jul 12 10:59:59 2010 UTC
# Line 287  sub cpr_m02_checksum { Line 287  sub cpr_m02_checksum {
287  }  }
288    
289  sub cpr {  sub cpr {
290          my $hex = shift;          my ( $hex, $description ) = shift;
291          my $bytes = str2bytes($hex);          my $bytes = str2bytes($hex);
292          my $len = pack( 'c', length( $bytes ) + 3 );          my $len = pack( 'c', length( $bytes ) + 3 );
293          my $send = $len . $bytes;          my $send = $len . $bytes;
294          my $checksum = cpr_m02_checksum($send);          my $checksum = cpr_m02_checksum($send);
295          $send .= $checksum;          $send .= $checksum;
296    
297          warn ">> ", as_hex( $send );          warn ">> ", as_hex( $send ), "[$description]\n";
298          writechunk( $send );          $port->write( $send );
299          my $r_len = read_bytes( 1, 'response length' );          my $r_len = $port->read(1);
300            warn "<< response len: ", as_hex($r_len), "\n";
301          $r_len = ord($r_len) - 1;          $r_len = ord($r_len) - 1;
302          my $data = read_bytes( $r_len, 'data' );          my $data = $port->read( $r_len );
303          warn "<< ", as_hex( $data );          warn "<< ", as_hex( $data );
304    
305            warn "## ",dump( $port->read(1) );
306  }  }
307    
308  cpr( '00  52 00' );  #cpr( 'FF  52 00', 'detect boud rate' );
309    
310    #cpr( '00  65', 'software version' );
311    
312    cpr( 'FF  65', 'get ? info' );
313    
314    cpr( 'FF  69 00', 'get reader info' );
315    
316    cpr( 'FF B0 01 00', '?' );
317    
318    cpr( 'FF 69', '?' );
319    
320    #cpr( '', '?' );
321    
322  exit;  exit;
323  # initial hand-shake with device  # initial hand-shake with device
# Line 654  sub read_bytes { Line 669  sub read_bytes {
669                  my ( $c, $b ) = $port->read(1);                  my ( $c, $b ) = $port->read(1);
670                  die "no bytes on port: $!" unless defined $b;                  die "no bytes on port: $!" unless defined $b;
671                  warn "## got $c bytes: ", as_hex($b), "\n";                  warn "## got $c bytes: ", as_hex($b), "\n";
672                    last if $c == 0;
673                  $data .= $b;                  $data .= $b;
674          }          }
675          $desc ||= '?';          $desc ||= '?';

Legend:
Removed from v.82  
changed lines
  Added in v.83

  ViewVC Help
Powered by ViewVC 1.1.26