/[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 83 by dpavlin, Mon Jul 12 10:59:59 2010 UTC revision 84 by dpavlin, Mon Jul 12 11:46:21 2010 UTC
# Line 10  use Getopt::Long; Line 10  use Getopt::Long;
10  use File::Slurp;  use File::Slurp;
11  use JSON;  use JSON;
12  use POSIX qw(strftime);  use POSIX qw(strftime);
13    use Time::HiRes;
14    
15  use IO::Socket::INET;  use IO::Socket::INET;
16    
# Line 280  sub cpr_m02_checksum { Line 281  sub cpr_m02_checksum {
281                                  $crc = $crc >> 1;                                  $crc = $crc >> 1;
282                          }                          }
283                  }                  }
284                  warn sprintf('%d %04x', $i, $crc & 0xffff);  #               warn sprintf('%d %04x', $i, $crc & 0xffff);
285          }          }
286    
287          return pack('v', $crc);          return pack('v', $crc);
# Line 296  sub cpr { Line 297  sub cpr {
297    
298          warn ">> ", as_hex( $send ), "[$description]\n";          warn ">> ", as_hex( $send ), "[$description]\n";
299          $port->write( $send );          $port->write( $send );
300    
301          my $r_len = $port->read(1);          my $r_len = $port->read(1);
302    
303            while ( ! $r_len ) {
304                    warn "# wait for response length 0.050\n";
305                    Time::HiRes::sleep 0.050;
306                    $r_len = $port->read(1);
307            }
308    
309          warn "<< response len: ", as_hex($r_len), "\n";          warn "<< response len: ", as_hex($r_len), "\n";
310          $r_len = ord($r_len) - 1;          $r_len = ord($r_len) - 1;
311          my $data = $port->read( $r_len );          my $data = $port->read( $r_len );
312          warn "<< ", as_hex( $data );          warn "<< ", as_hex( $data );
313    
314          warn "## ",dump( $port->read(1) );          Time::HiRes::sleep 0.050;
315  }  }
316    
317  #cpr( 'FF  52 00', 'detect boud rate' );  #cpr( 'FF  52 00', 'detect boud rate' );

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

  ViewVC Help
Powered by ViewVC 1.1.26