Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by hennesse (Sexton)
on Nov 02, 2011 at 01:29 UTC ( #935262=note: print w/ replies, xml ) Need Help??


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

BrowserUK, Marshall, and afoken,

Thank you for your suggestions. I'm hoping to market my Perl->RS232->RS485 application, and that means fitting in a variety of real-world situations -including computers that don't have serial ports (imagine that!) There are several options for the RS-485 conversion, and I need to find the "best" option

USB to RS-232 converter
Most desirable. Most people will be using an older PC for this "semi-dedicated" application, so my program will run as is. For a new computer without a serial port, there would be no changes to my program - assuming the converter includes software that allows it to be addressed as COM1.
Of course, in a few years, "older" PCs won't have serial ports either. So I'm gonna have to learn USB sooner or later...
USB to RS-485 converter
Middle desirable. If the converter comes with a "COM1 option", it rivals the first choice. Otherwise, it means rewriting my software for USB. I have no idea what that would entail, but I suspect that it would be painful - and device manufacturer-dependent.
RS-485 PC card
Least desirable. The target market are techie-hobbyists, but not necessarily computer techies. They're not going to want to take apart their computers.

You've pointed me in the right direction. Now I have to do my homework... As GrandFather suggested, I will eventually be doing some TITS. But the less "shelfware" I have to purchase, the better.

Thanks - Dave


Comment on Re^2: Win32::SerialPort v. New computers
Re^3: Win32::SerialPort v. New computers
by GrandFather (Cardinal) on Nov 02, 2011 at 02:20 UTC

    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

      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". ;-)

      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". ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-07-24 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (160 votes), past polls