From de06eedd1d632efddb05fcb4a5188376bc11f3a2 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 9 Nov 2017 21:39:26 +0100 Subject: [PATCH] working on rpi 3, not really useful on old 4.9 kernel --- gpio.pl | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/gpio.pl b/gpio.pl index a2895c1..4491529 100755 --- a/gpio.pl +++ b/gpio.pl @@ -40,12 +40,17 @@ my $line_i = 0; my $include = 0; while() { chomp; - if ( m/^#\s*$model/ ) { - $include = 1; + if ( m/^#\s(.+)/ ) { + warn "MODEL [$1] == [$model] ?\n"; + if ( $model =~ m/$1/ ) { + $include = 1; + } else { + $include = 0; + } } elsif ( m/^#\s+/ ) { - $include = 0; + $include = 1; } elsif ( $include ) { - push @{ $pins->{$1} }, $line_i while ( m/\t(P\w\d+)/g ); + push @{ $pins->{$1} }, $line_i while ( m/\t(\w+\d+)/g ); push @lines, $_; @@ -64,7 +69,7 @@ my $pin_function; open(my $fh, '<', '/sys/kernel/debug/pinctrl/pinctrl-handles'); while(<$fh>) { chomp; - if ( m/group: (P\w\d+)\s.+function: (\S+)/ ) { + if ( m/group: (\w+\d+)\s.+function: (\S+)/ ) { my ($pin, $function) = ($1,$2); $pin_function->{$pin} = $function; @@ -88,6 +93,8 @@ warn "XXX $pin $line"; } } +warn "# pin_function = ",dump($pin_function); + my @max_len = ( 0,0,0,0 ); my @line_parts; foreach my $line (@lines) { @@ -231,6 +238,7 @@ my $line_fmt = qq{