Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Win32::SerialPort v. New computers

by GrandFather (Saint)
on Nov 02, 2011 at 02:20 UTC ( [id://935267]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Win32::SerialPort v. New computers
in thread Win32::SerialPort v. New computers

For this sort of application you are never going to have to "learn USB" in order to drive a serial port. The driver stack for the USB device isolates you from having to know anything about the USB layer - you simply use the usual OS provided API for the device. In the current case, so long as you are using the Windows provided serial API (which, as far as I know Win32::SerialPort does), it really doesn't matter if you use a serial port provided on the computer's mother board, or on an ISA card, or by a PCMCIA card or as a USB/serial dongle. The hard wired COM1 constrain however will cause you grief real quick!

Using the module which (I presume) uses the Windows serial API allows any of the three options you've suggested without any code changes aside from configuration issues such as the COM port used.

True laziness is hard work

Replies are listed 'Best First'.
Re^4: Win32::SerialPort v. New computers
by afoken (Chancellor) on Nov 02, 2011 at 10:52 UTC

    Some USB-to-RS232 adapters (Logilink, perhaps others) come with a litte tool that allows setting the COM port number from the Windows-assigned number (typically >4) to lower numbers (down to COM1).

    COM1 to COM9 should be no problem for most software that uses the Windows API, COM10 and higher need some obscure syntax to specify the COM port (\\.\COM10, according to http://support.microsoft.com/kb/115831).

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^4: Win32::SerialPort v. New computers
by hennesse (Beadle) on Nov 03, 2011 at 03:24 UTC

    GrandFather,

    I feel soooo stupid. I happened to already have one of these in my "shelfware" box, but I didn't realize it.

    About a year ago, I ordered an RS-232->RS-485 converter from Omega Engineering and they sent me a USB->RS-232 converter by mistake. I offered to send the wrong one back, and they said "Aww, just toss it", so I tossed it in my shelfware box, and then totally forgot about it.

    Subsequent to my posting, I started thinking "What was that wrong thing?", and dug through the shelfware box. Sure 'enuf...

    Works as advertised - running the device's "Install" program makes it becomes a COM port, and Win32::SerialPort talks to it just fine.

    NOTES:

    The device becomes a different COM ports on different computers (e.g. COM6, COM11).

    This particular imported no-name USB->RS-232 device was based on the Prolific (a Taiwanese company) PL-2303 chips, as I suspect many commercially available models are. Use the install software that comes with the device - NOT a generic driver from Prolific. Make sure the device says it supports Windows 7 if that's what you're going to use it on. I installed it successfully on one XP computer using the device manufacurer's software. When I tried in on another XP computer using Prolific's generic sofware from their website - it failed miserably. Reboot after installing -even if it doesn't tell you to do so.

    Sorry to bother everone with this question,

    Dave

      The device becomes a different COM ports on different computers (e.g. COM6, COM11).

      Well-known behaviour of most USB-to-RS232 adapters with Windows. It depends on the available internal COM ports (based on 8250 / 16450 / 16550 and clones), the virtual COM ports that once were used (e.g. by other USB-to-RS232 adapters or Bluetooth devices), and sometimes even on the actual USB port into which you plug the adapter. Someone at Microsoft must have decided that it is a good idea to reserve COM ports for devices that had been plugged in ages ago.

      This particular imported no-name USB->RS-232 device was based on the Prolific (a Taiwanese company) PL-2303 chips, as I suspect many commercially available models are. Use the install software that comes with the device - NOT a generic driver from Prolific. Make sure the device says it supports Windows 7 if that's what you're going to use it on. I installed it successfully on one XP computer using the device manufacurer's software. When I tried in on another XP computer using Prolific's generic sofware from their website - it failed miserably. Reboot after installing -even if it doesn't tell you to do so.

      There seem to be two different kinds of such adapters. Some identify as a generic RS232 adapter and are supported out-of-the-box by the drivers that came with Windows. And the other ones need vendor- or chipset-specific drivers. I would try to avoid the second type, because no vendor spends much money on testing the driver software for a device that costs less than 6 €. Most vendor drivers seem to be rebranded chipset drivers from the chipset manufacturer.

      Note that Linux handles USB-to-RS232-adapters a little bit different: The first free device name is assigned, typically /dev/ttyUSB0 for the first adapter, /dev/ttyUSB1 for the second one, and so on. No reserved devices. Unless you configure udev to identify a certain adapter by its vendor and device ID and its serial number and to assign it a constant device name. Other adapters will still get the first free device name.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        Alexander,

        The device works OK, with one little problem. When I initialize the COM port with the USB->RS232 converter, one of my pumps spins for a fraction of a second. This does not happen with the native RS-232 serial port. I fear the win32 device may have been infected with a certain virus.

        The RS-232 does go to RS-485 to an industrial process control system with (not Siemens) PLCs, and might, at a real stretch, be considered a SCADA system. But the USB->RS-232 conveter does seem to issue a #030SB09 command immediately followed by a #030CB09 command - which would make the pump start and immediately stop.

        Dear National Security Agency - this is a beer brewery, not a calutron or gas centrifuge. Please remove "Stuxnet".

        Thanks - Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://935267]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-03-29 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found