Quiet down linux USB port detection in cases where everything works ok

pull/357/head
Jesse Vincent 6 years ago
parent 6ef86cfe5a
commit edd671cd41

@ -18,18 +18,29 @@ use strict;
use FindBin qw{$Bin}; use FindBin qw{$Bin};
die "Usage: $0 VID PID\n" unless @ARGV == 2; die "Usage: $0 VID PID [-v]\n" unless @ARGV >= 2;
my $vid = shift; my $vid = shift @ARGV;
my $pid = shift; my $pid = shift @ARGV;
my $verbose = shift @ARGV if (@ARGV);
my $prefix = '/dev/serial/by-id/'; my $prefix = '/dev/serial/by-id/';
my @paths = `ls $prefix`; my @paths = `ls $prefix`;
my %devices; my %devices;
my @log;
sub debug { sub debug {
if ($verbose) {
print STDERR @_;
} else {
push @log, @_;
}
}
sub print_warning {
print STDERR @_; print STDERR @_;
} }
debug "Looking for USB device with vid=$vid and pid=$pid\n"; debug "Looking for USB device with vid=$vid and pid=$pid\n";
for my $path (@paths) { for my $path (@paths) {
@ -60,7 +71,7 @@ for my $path (@paths) {
if ( $devices{$path}{'ID_MM_CANDIDATE'}) { if ( $devices{$path}{'ID_MM_CANDIDATE'}) {
my $rules = "$Bin/../etc/99-kaleidoscope.rules"; my $rules = "$Bin/../etc/99-kaleidoscope.rules";
debug <<EOWARN print_warning <<EOWARN
WARNING: your udev rules are currently configured to suggest WARNING: your udev rules are currently configured to suggest
that your keyboard is suitable for use by ModemManager. This that your keyboard is suitable for use by ModemManager. This
@ -76,3 +87,7 @@ EOWARN
print $devices{$path}{DEVNAME}; print $devices{$path}{DEVNAME};
exit(0); exit(0);
} }
print_warning(join("\n",@log));
print_warning("ERROR: I couldn't find a USB device matching the keyboard's USB Vendor and Device IDs\n");

Loading…
Cancel
Save