http://www.perlmonks.org?node_id=185213

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

A little background:
I have a VScomm PCI-200L dual serial port board installed and the ports are set to COM5 and COM6.

A script that uses Win32::SerialPort to communicate with some hardware via the serial port which works fine as long as I use the "on-motherboard" COM ports (COM1, COM2). Once I move the device to the add-on board, communication ceases.

The script reports no errors opening COM6 but never "sees" any data sitting on the port. To add a twist to this all dilemma I have a Win32 App that came with the hardware and it can communicate with the hardware when connected to COM6 just fine.

So my question is this, is there a known limitation with Win32::SerialPort and COM ports greater than 4? Or a known issue when used in conjunction with a serial port expansion board? Or is there some completely obvious setting that I'm overlooking (this is the most likely scenario).

-Nitrox

Replies are listed 'Best First'.
Re: Win32::SerialPort with ports > 4
by RMGir (Prior) on Jul 25, 2002 at 15:21 UTC
    Back in the "good old days", problems like this came up because COM5 and COM6 didn't have standard IRQ and port assignments.

    But looking at the Win32::SerialPort docs, that doesn't look like it's the problem. W32::SP seems to expect to find the port in the registry.

    I don't have a serial port on this box here, but do a quick search under \\HKEY_LOCAL_MACHINE\HARDWARE for COM1, and see if COM6 is defined there. (I hope that's where com ports would be...)

    It's possible your other applications are finding it via "well known" IRQ/IO settings, and not via the registry.

    If it's not in your registry, how to add it will depend on your version of Windows, unfortunately. Look for "Ports" in the Control Panel, if you're lucky.
    --
    Mike

Re: Win32::SerialPort with ports > 4
by Nitrox (Chaplain) on Jul 25, 2002 at 18:46 UTC
    Ok, I reinstalled the card, swapped some cables around but it's still a no go.

    In the registry is:
    \Device\Serial0 ... COM1
    \Device\Serial1 ... COM2
    \Device\vspciser0 ... COM4
    \Device\vspciser1 ... COM5
    Winachsf0 ... COM3

    The setup runs fine on COM1 and COM2, and when on COM4 or COM5 the script returns no errors when opening the port but still never "sees" any data on the port. If I shutdown the script and launch the win32 app it reads the waiting data.

    -Nitrox

      Hmmm... Did you try referring to it with the "vspciser0" name? There's an example in the perldocs that shows that usage.

      That's just a wild guess, though. :(
      --
      Mike

Re: Win32::SerialPort with ports > 4
by Nitrox (Chaplain) on Aug 10, 2002 at 14:10 UTC
    This has been resolved! I replaced the 'VScomm PCI-200L' card with a 'RocketPort PCI 4J' and my conflict with setting the baud rate went away. Live and learn...

    -Nitrox

Re: Win32::SerialPort with ports > 4
by Nitrox (Chaplain) on Jul 25, 2002 at 20:22 UTC
    Nadda, throws a "Cannot open port" error. -Nitrox
Re: Win32::SerialPort with ports > 4
by Nitrox (Chaplain) on Jul 26, 2002 at 12:29 UTC
    I have an update on this. I used portmon to watch the ports as I connect to them and I see the problem.

    Here's a snippet of my test stub:

    my $ob = Win32::SerialPort->new("COM5") || die("Couldn't open COM5"); $ob->baudrate(19200); $ob->parity("none"); $ob->databits(8); $ob->stopbits(1); $ob->handshake("none"); $ob->write_settings || die("Couldn't write serial port settings");
    When I run this with COM1 (a motherboard port) portmon reports that it was opened at 19200b, which is what was requested. However, when I run this with COM5 (the add-on card) portmon reports that it was opened at 1200b. Any ideas to why the add-on card would be ignoring the baudrate request?

    -Nitrox