$|=1; # flush stdout
-require 'gpio.pl';
+my $have_gpio = `which gpio`;
+warn "# ", ! $have_gpio ? "DOESN'T " : '', "have rpi gpio\n";
+require 'gpio.pl' if $have_gpio;
open(my $bsdl, '<', $bsdl_file);
while(<$bsdl>) {
chomp;
my ($pin,$desc, $bcm) = split(/\t+/,$_,3);
$pin_desc->{$pin} = $desc;
- gpio::add_bcm_desc( $bcm => $desc );
+ gpio::add_bcm_desc( $bcm => $desc ) if $have_gpio;
}
close($fh);
warn "# $pin_file ",dump($pin_desc);
}
}
- printf "%-3d %-3d %-5s %3s %-8s | ", $pin, $o, $io, $bits, $desc;
+ $desc = ' ' . $desc if length($desc) < 10;
+ $desc = substr($desc,0,10);
+
+ printf "%-3d %-3d %-5s %3s%-10s| ", $pin, $o, $io, $bits, $desc;
} else {
- printf "%-3d ... %-18s | ", $pin, $io, '', '';
+ printf "%-3d ... %-18s | ", $pin, $io;
}
}
print "\n";
diff_bits($BSR, $bin);
$BSR = $bin;
print_io $bin if $bin ne $last_bits;
- gpio::pins();
+ gpio::pins() if $have_gpio;
last;
} else {
warn "# in ",dump($_);
print "# diff_bits $diff\n";
}
-print "[press enter]\n";
+print "> ";
my $cmd = <STDIN>;
chomp $cmd;
if ( $cmd =~ /(p|o)(\d+)=(\d+)/ ) {
print $sock "irscan $tap $opcode->{SAMPLE}\n"; # SAMPLE/PRELOAD
print $sock "drscan $tap $BOUNDARY_LENGTH 0\n";
} else {
- gpio::cmd( $cmd );
+ gpio::cmd( $cmd ) if $have_gpio;
print $sock "irscan $tap $opcode->{SAMPLE}\n"; # SAMPLE/PRELOAD
print $sock "drscan $tap $BOUNDARY_LENGTH 0\n";
}