You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
562 B
25 lines
562 B
6 years ago
|
#!/usr/bin/env perl
|
||
|
|
||
|
use warnings;
|
||
|
use strict;
|
||
|
|
||
|
#
|
||
|
# Scan all USB devices to find the Model 01's modem device number.
|
||
|
#
|
||
|
my @output = qx(/usr/sbin/usbconfig show_ifdrv);
|
||
|
my $serial_port_number;
|
||
|
|
||
|
foreach my $line (@output) {
|
||
|
chomp $line;
|
||
|
|
||
|
next unless $line =~ m/umodem(\d+):.*Keyboardio Model 01/;
|
||
|
$serial_port_number = $1;
|
||
|
}
|
||
|
|
||
|
die "Can't find Model 01" unless defined($serial_port_number);
|
||
|
|
||
|
my $serial_port_name = "/dev/cuaU$serial_port_number";
|
||
|
die "Missing serial port at $serial_port_name" unless -e $serial_port_name;
|
||
|
print "$serial_port_name\n";
|
||
|
exit 0;
|