my $openocd_remote = shift @ARGV || 'picam:4444';
+
my $bit2pin;
my $io2bit;
$aa <=> $bb } keys %$io2bit;
warn "# sort = ",dump(@sort);
+my $last_bits = '';
sub print_io {
my $bits = shift;
- my $i = 0;
-# foreach my $io ( @sort ) {
- print "pin off io___ I C O | " x 4, $openocd_remote,"\n";
+ $bits = reverse $bits; # make substr work as expected
+
+ return if $last_bits eq $bits;
+
+ print "pin off io___ ICO prv | " x 4, $openocd_remote,"\n";
foreach my $i ( 0 .. ($#$pin2io/4)-1 ) {
foreach my $j ( 0 .. 3 ) {
#my $pin = ($i*4) + $j + 1; # rows
my $io = $pin2io->[$pin];
my $o = $io2bit->{$io}->[0];
if ( defined $o ) {
- printf "%-3d %-3d %-5s %d %d %d | ", $pin, $o, $io, split(//, substr($bits, $o, 3));
+ my $l = $b = substr($bits, $o, 3);
+ $l = substr($last_bits,$o,3) if $last_bits;
+ printf "%-3d %-3d %-5s %3s %3s | ", $pin, $o, $io, $b, $b ne $l ? $l : ''
} else {
- printf "%-3d ... %-5s | ", $pin, $io;
+ printf "%-3d ... %-5s %3s %3s | ", $pin, $io, '', '';
}
}
print "\n";
}
print "\n";
+ $last_bits = $bits;
}
#foreach my $h (qw(0 1 2 e f 10 11 12 1e 1f 20 30 40 50 100 200 1000)) {
print "# diff_bits $diff\n";
}
-print "[press enter]\n";
-my $cmd = <STDIN>;
+my $cmd = '';
+if ( $ENV{SLEEP} ) {
+ sleep $ENV{SLEEP};
+ $cmd = <DATA>;
+ exit if ! $cmd;
+} else {
+ print "[press enter]\n";
+ $cmd = <STDIN>;
+}
chomp $cmd;
+
if ( $cmd =~ /(\d+)=(\d)/ ) {
my ( $pin, $v ) = ( $1, $2 );
warn "# pin $pin = $v\n";
my $io = $pin2io->[$pin];
my $bit = $io2bit->{$io}->[0];
- my $b = substr($BSR,0,$bit+1)
- . ( substr($BSR,$bit+1,1) ^ 1 )
+ my $old_bsr = reverse $BSR;
+
+ my $b = substr($old_bsr,0,$bit+1)
+ . ( substr($old_bsr,$bit+1,1) ^ 1 )
. ( $v & 1 )
- . substr($BSR,$bit+3)
+ . substr($old_bsr,$bit+3)
;
+ $b = reverse $b;
diff_bits( $BSR, $b ), $/;
}#while(1)
+
+__DATA__
+5=1
+a
+b
+c
+d
+e
+f
+a
+a
+a
+a
+a
+a
+a
+a
+a
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+b
+c
+d
+e
+f
+5=0
+a
+b
+c
+d
+e
+f