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

Copied from http://stackoverflow.com/questions/25799890/win32serialport-cant-find-device, as I didn't get a response.

I'm writing a perl script where I need to read and write to a device connected by serial, and it always fails with "can't find device".

Here is the relevant code:

my $portObj = new Win32::SerialPort("COM67") || return "0";

This fails and returns 0. I confirmed that the device was present in device manager. I did see that COM1 and COM3 ports did work, while COM67 and COM22 did not.

I hope maybe it's some kind of silly string error related to a 5 character port name...

But I think the device doesn't allow writes or something and that's causing this issue. But if that was the case, I would expect it to only cause problems when I attempt a write. I've used a terminal program (putty) to read from the device so I know reads are possible.

Also, worst case scenario, I can rearrange the code so that I only need read capability. This is a much less ideal solution though.

Replies are listed 'Best First'.
Re: Win32::SerialPort can't find device
by ww (Archbishop) on Sep 12, 2014 at 22:53 UTC
    Google (search terms: "Serial port designations in Win32") is your friend (sometimes):
    http://www.tetraedre.com/advanced/serial2.php?new_lang=en re Development of VHDL & Verilog modules

    which says, among many other things:

    COM10 and above
    On Microsoft Windows, you can use COM1 to COM9 to access serial ports but to access ports with numbers above 9, you need to use the following port name : \\.\COM10.
    Note that it is also possible to used \\.\COM1 to access COM1.

    Don't know if this is relevant to your problem but here's hoping it some help.


    ++$anecdote ne $data