show diffs between BSR states
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 10 Jun 2016 21:35:25 +0000 (23:35 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 10 Jun 2016 21:35:25 +0000 (23:35 +0200)
correct also pin mapping since I'm extracting bits using substr
from left-to-right i have to reverse pins before displaying them

openocd-jtag-boundary-scan.pl

index b2a2794..dafd874 100755 (executable)
@@ -65,11 +65,12 @@ my @sort = sort {
        $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
+
+       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
@@ -77,14 +78,17 @@ sub print_io {
                        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)) {