--- cpr-m02.pl 2010/07/12 10:59:59 83 +++ cpr-m02.pl 2010/07/12 11:46:21 84 @@ -10,6 +10,7 @@ use File::Slurp; use JSON; use POSIX qw(strftime); +use Time::HiRes; use IO::Socket::INET; @@ -280,7 +281,7 @@ $crc = $crc >> 1; } } - warn sprintf('%d %04x', $i, $crc & 0xffff); +# warn sprintf('%d %04x', $i, $crc & 0xffff); } return pack('v', $crc); @@ -296,13 +297,21 @@ warn ">> ", as_hex( $send ), "[$description]\n"; $port->write( $send ); + my $r_len = $port->read(1); + + while ( ! $r_len ) { + warn "# wait for response length 0.050\n"; + Time::HiRes::sleep 0.050; + $r_len = $port->read(1); + } + warn "<< response len: ", as_hex($r_len), "\n"; $r_len = ord($r_len) - 1; my $data = $port->read( $r_len ); warn "<< ", as_hex( $data ); - warn "## ",dump( $port->read(1) ); + Time::HiRes::sleep 0.050; } #cpr( 'FF 52 00', 'detect boud rate' );