From 765a058664f296289fe3358b3f2ed36e8da97446 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 6 Jul 2016 11:21:43 +0200 Subject: [PATCH] fix diff_buts for BOUNDARY_LENGTH which are not multiple of 8 bits --- openocd-jtag-boundary-scan.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openocd-jtag-boundary-scan.pl b/openocd-jtag-boundary-scan.pl index 4e3632c..3634bbe 100755 --- a/openocd-jtag-boundary-scan.pl +++ b/openocd-jtag-boundary-scan.pl @@ -251,19 +251,22 @@ while (<$sock>) { sub diff_bits { my ($old, $new) = @_; + $old = reverse $old; # extra bits must be on the end + $new = reverse $new; $old =~ s/(...)/$1 /g; $new =~ s/(...)/$1 /g; my @o = split(/ /, $old); my @n = split(/ /, $new); - foreach my $i ( 0 .. $#o ) { + my $bsr_max_bit = $BOUNDARY_LENGTH / 3 - 1; + foreach my $i ( 0 .. $bsr_max_bit ) { if ( $o[$i] eq $n[$i] ) { $o[$i]='.'; } else { - my $pin = $bit2pin->{ $BOUNDARY_LENGTH - ($i * 3) - 3 }->[0]; + my $pin = $bit2pin->{ $i * 3 }->[0]; $o[$i] = " $pin@" . ( $i * 3 ) . ":" . $o[$i] . '>' . $n[$i]; } } - my $diff = join('', @o); + my $diff = join('', @o[ 0 .. $bsr_max_bit ]); print "# diff_bits $diff\n"; } -- 2.20.1