Thread: Change COM Ports

  1. #1
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59

    Question Change COM Ports

    I am using a USB device that emulates a serial port. I need the device to be assigned to COM1 everytime it is plugged in. Is there a way to programmatically clear COM1 and then reassign my device to COM1 upon request?

    When I plug the device into various machines, it will obtain which ever COM port is free and it is usually not COM1. I am told by my superiors that I can bump any devices off of COM1, so I do not have to worry about that.

    Any help would be appreciated.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    The ability to do this is totally dependent on the device driver.

    Why does it need to be on COM1? Why not just open the correct port?

    gg

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Codeplug View Post
    The ability to do this is totally dependent on the device driver.

    Why does it need to be on COM1? Why not just open the correct port?

    gg
    My guess would be that the software that opens the port is "stupid".

    I agree that the driver may or may not pick COM1 even if the driver is the ONLY COM-port driver - although good drivers should pick COM1 if the driver is "alone" on the system.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Since XP allows you to go into device manager and reassign comm ports, I am assuming that it can be don at the OS level. I was just wondering if anyone has an idea of how and what the Device Manager UI is changing.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> Since XP allows you to go into device manager and reassign comm ports...
    Only if the driver provides additional UI. The default MS driver for "real" ports does not.

    I've worked with several virtual COM port drivers that do one of the following on installation:
    1) always choose a fixed port
    1a) if chosen port fails installation, then try port + 1
    1b) some start of port 15 and won't do anything lower
    2) use a configuration file / GUI / installation asks or provides unattended setting
    3) enumerate existing ports, taking the first available port#

    For #3, how the "enumeration" is actually done varies. I've seen drivers try to settle on a port # that's already taken by another virtual port driver and just fail installation.

    After installation, some virtual COM drivers provide a GUI to modified the port # - some via device manager property page, and some with their own config application, or both.

    >> Why does it need to be on COM1? Why not just open the correct port?

    gg

  6. #6
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    The application we are dealing with reads and writes to a device via COM1. I do not have control over the code and I am not able to convince my counterparts to make code adjustments on an application that works. (We are transferring data from outdated hardware running Win 98).

    When I connect the device to an XP machine, it can end up on any open com but the legacy software will only look for it on COM1.

    I am not aware of any config files with the drive but I will look into it.

    Thanks for the idea. At least I have something to look for now.

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You could run this legacy app in a virtual machine (on a legacy OS even). Then you can map the VM's COM1 to any of the host's COM ports.

    gg

  8. #8
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Nope. The app runs inside a box that we simply connect to our XP boxes via USB. That "box" connects to sensors and it collects readings that I need to retrieve and monitor.

  9. #9
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> When I connect the device to an XP machine, it can end up on any open com but the legacy software will only look for it on COM1.
    That tells me that the legacy software runs on the XP machine and communicates with the "box" on COM1.

    >> Nope. The app runs inside a box that we simply connect to our XP boxes via USB.
    Now the "legacy app" is running on the "box"...? Is the virtual com port driver running on the XP machine or "box"?

    gg

  10. #10
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    There is a legacy app on the "box" and a receiver side is running on our XP PCs. The receiver portion expects to read data on COM1. The portion in the "box" is Win 95.
    Last edited by JustMax; 03-18-2009 at 01:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. type casting?
    By greatonesv in forum C Programming
    Replies: 12
    Last Post: 10-22-2008, 08:21 PM
  2. c++builder6 change form names problem
    By Leite33 in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2008, 08:20 AM
  3. Change Value in an array
    By beginner999 in forum C Programming
    Replies: 3
    Last Post: 01-18-2003, 07:16 AM
  4. Replies: 2
    Last Post: 11-08-2002, 03:22 AM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM