From 1fd28f9fb9b24ad4e1b21f3d504409e9defaabe6 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 11 May 2018 09:36:19 +0200 Subject: [PATCH] fix --pins usage and filtering of boards in same pins file This allows us to have Raspberry Pi pin description in single file, by specifing common prefix for shared pins and more specific model filter to show just appropriate pins --- gpio.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gpio.pl b/gpio.pl index 8c5a532..0e75092 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, $_; -- 2.20.1