X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=gpio.pl;h=99e1703db13102d522e4a10a100cab8e472b83f4;hb=HEAD;hp=8c5a532d2e82398ecd3e8e5a812ed8c282afc9e8;hpb=bf4b68b7d94f844a3e346f828d4e3c4610d57541;p=linux-gpio-pinout diff --git a/gpio.pl b/gpio.pl index 8c5a532..99e1703 100755 --- a/gpio.pl +++ b/gpio.pl @@ -47,10 +47,19 @@ sub slurp { } my $pins; +my $include = 0; my $model = slurp('/proc/device-tree/model'); $model =~ s/\x00$//; # strip kernel NULL warn "# model [$model]"; +if ( $opt_pins ) { + $model = $opt_pins; + $model =~ s/^.*\///; # strip dir + $model =~ s/\..+$//; # strip extension + $include = 1; + warn "# $opt_pins model [$model] $include"; +} +warn "# $opt_pins model [$model] $include"; OPEN_PINS_AGAIN: open(DATA, '<', $opt_pins) if $opt_pins; @@ -58,17 +67,16 @@ open(DATA, '<', $opt_pins) if $opt_pins; my @lines; my $line_i = 0; -my $include = 0; while() { chomp; if ( m/^#\s(.+)/ ) { - warn "MODEL [$1] == [$model] ?\n"; if ( $model =~ m/$1/ ) { $include = 1; } else { $include = 0; } - } elsif ( $include || $opt_pins ) { + warn "MODEL [$1] == [$model] include: $include\n"; + } elsif ( $include ) { push @{ $pins->{$1} }, $line_i while ( m/\t\s*(\w+\d+)/g ); push @lines, $_; @@ -224,7 +232,7 @@ open(my $pio, '-|', 'raspi-gpio get'); while(<$pio>) { chomp; if ( m/^\s*GPIO (\d+): (.+)/ ) { - my $pin = 'gpio' . $1; + my $pin = 'gpio' . $1 * 1; # we need * 1 to strip leading zero push @gpio_pins, $1; annotate_pin $pin, $2 if ! $opt_svg; }