Fix serial port detection on Windows

This commit is contained in:
Alessandro Ranellucci 2015-11-06 16:25:51 +01:00
parent 9a8724cdd0
commit 5d69e732d8

View file

@ -320,16 +320,18 @@ sub scan_serial_ports {
if ($^O eq 'MSWin32') { if ($^O eq 'MSWin32') {
# Windows # Windows
my %reg; if (eval "use Win32::TieRegistry qw(KEY_READ); 1") {
if (eval "use Win32::TieRegistry (TiedHash => \\%reg); 1") { my $ts = Win32::TieRegistry->new("HKEY_CURRENT_USER\\HARDWARE\\DEVICEMAP\\SERIALCOMM",
push @ports, sort values %{$reg{"HKEY_CURRENT_USER\\HARDWARE\\DEVICEMAP\\SERIALCOMM"}}; { Access => KEY_READ });
$ts->Tie(\my %reg);
push @ports, sort values %$reg;
} }
} else { } else {
# UNIX and OS X # UNIX and OS X
push @ports, glob '/dev/{ttyUSB,ttyACM,tty.,cu.,rfcomm}*'; push @ports, glob '/dev/{ttyUSB,ttyACM,tty.,cu.,rfcomm}*';
} }
return @ports; return grep !/Bluetooth|FireFly/, @ports;
} }
1; 1;