Tweak location-based detection logic

Signed-off-by: Jesse Vincent <jesse@keyboard.io>
pull/841/head
Jason Koh 5 years ago committed by Jesse Vincent
parent b675ff2902
commit 430b159913

@ -69,10 +69,13 @@ sub try_for_raw_serialnum {
sub try_for_location_id {
my $location_id = shift;
# Here, also, the final character is always a "1", so if macOS ever stops doing that, this
# will need an update, as well.
my $loc = substr($location_id, 2, 3);
exit_with_port_if_exists("/dev/cu.usbmodem" . $loc . 1);
# macOS truncates the string of "0"s from the right of the location id.
# Here, also, the final character is an appended "1", so if macOS ever stops doing that,
# this will need an update, as well.
if ($location_id =~ /0x(\d+?)0*\b/) {
my $loc = $1;
exit_with_port_if_exists("/dev/cu.usbmodem" . $loc . "1");
}
}
sub try_for_sn_prefix {

Loading…
Cancel
Save