slloyd has asked for the wisdom of the Perl Monks concerning the following question:

I am using Win32::SerialPort to connect to my USB Serial Port device. When the device is assigned COM9, it connects just fine. If the device is assigned COM10 it fails to connect. Any pointers to connecting to ports greater than 9? I have verified that I have valid devices connected to both 9 and 10 and both show up as valid ports in HKEY_LOCAL_MACHINE, "Hardware\\DeviceMap\\SerialComm"

Update: I found this link on M$ site that explains the problem but I am not sure if the SerialPort module needs to be fixed to support it or if there is a work-around.

WorkAround: The work-around is to pass in the port name as "\\.\COMXX" where XX is the number. This works for me anyway.

#!perl use strict; use Win32::SerialPort; my $port=shift || "COM9"; print "Connecting to $port .... "; our $PortObj = new Win32::SerialPort($port); unless(ref $PortObj){ print "Unable to connect to $port\n"; exit; } print "Connected!\n"; print "Press <ENTER> to disconnect"; my $cmd=<STDIN>; $PortObj->close(); exit(0);
Results:
C:\Automation>test.pl COM9
Connecting to COM9 .... Connected!
Press <ENTER> to disconnect

C:\Automation>test.pl COM10
Connecting to COM10 .... The system cannot find the file specified.
can't open device: COM10
 at C:\Automation\test.pl line 7
Unable to connect to COM10

C:\Automation>test.pl \\.\COM10
Connecting to \\.\COM10 .... Connected!
Press <ENTER> to disconnect

s/te/ve/

Replies are listed 'Best First'.
Re: Connecting to Serial Ports greater than COM9 on win32
by Anonymous Monk on Dec 08, 2017 at 06:13 UTC
    hey i tried giving the ComPort input in the way you have done, it still says the same thing. Can you please help me or suggest some other modules that i can use??