This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CDC Virtual Com Port Assignment

Hello,

Is there any solution to have device virtual com ports allocated for example from COM14 onwards? There is a solution for the FTDI chip described in chapter 6.8, see the spec http://www.ftdichip.com/Support/Documents/AppNotes/AN_107_AdvancedDriverOptions_AN_000073.pdf

Now, we are running on TI MCU and we are facing an issue with the Virtual Com Port. Sometimes it is assigned to COM3 (although already used by Bluetooth device)

Thank you very much for your support

Best regards,

Vlastimil Petrucha

  • Once the VCP has been created, you can go into the device manager and manually assign it a COM port. Windows should save this manual override and apply it once the device is plugged-in next time.

    Keep in mind that depending on the way software is enumerating available COM ports, ports >7 or >15 cannot be "detected" by some software. It's a Windows limitation that depends on the used API for COM access.

  • Hello Jens-Michael

    To change the COM port manually in device manager is not acceptable for our customers. I need to find out software solution.

    Best regards
    Vlastimil Petrucha

  • Vlastimil Petrucha said:
    To change the COM port manually in device manager is not acceptable for our customers.

    You forgot to mention that the solution is for your customers, not for you :)

    I don't think it is possible. It migh tbe possible to define a fixed COM port nr (which would probably interfere with other drivers, causing your customers to get angry) or leave it to windows. Just limiting the range for auto-assignments is IMHO not an option. Of course you can write an installer that manually patches the registery entry on driver installation, after asking the user for a COM port he wants to use :)

  • Hello Jens-M,

    Yes, You are right, I did not mention that fact :)

    Fixed COM number really does not meet our requirements.

    Patching registry entries sounds better for me. Do you know any link with source code examples? I am not expert in VCP so I am not sure which registers needs to be updated. Also I have to be sure the registry patch will not brake a "COM Port database" functionality. A simple example in c# would be appreciated :)

    Thank you

    Regards
    Vlastimil Petrucha

  • Instead of reassigning the COM number, would looking up the device's COM number by VID and PID be an acceptable solution? If so, I have written C code that does that. Let me know if this would be helpful.

  • Even if Vlastimil Petrucha is not interested in that - I am, I was facing some similar problems with one of my tools - it was only for my personal use so I could live with the inconvenience of checking the COM port numbers manually, but for a more sophisticated tool - especially for others an auto detection would be great.

  • Hello Alexander,

    In my app I also do the searching for COM port based on the VID/PID. The issue I highlited in this thread is that after driver instalation there happened the COM x is assigned for 2 devices (i.e. Bluetooth(COM3) and MyDevice(COM3)). This causes MyDevice is not working. Therefore I am trying to find any software solution to reassign MyDevice(COM3) to any free COM port.

    There are probably some solutions (devcon, setupAPI, registry patching...). Do you have any advice how to work it out?

    Thank you
    Regards

    Vlastimil Petrucha

  • Vlastimil Petrucha said:
    after driver instalation there happened the COM x is assigned for 2 devices (i.e. Bluetooth(COM3) and MyDevice(COM3))

    The Wonders of Windows!
    Normally, this shouldn't happen. But if the BT driver was installed last and used a workaround to ensure a fixed COM port (because the application developers were too lazy to search for the right port), then of course this is a problem if this poret was already assigned to a different device (yours). The very same hitting can also happen with network drives and drive letters, if an USB stick got the very same drive letter assigned.

    A possible workaround is to write a driver loader that checks whether the intended COM port is already in use when the driver for your device is loaded, and then change it automatically to the next free number. Or to simply remove the COM port assignment from registery when the driver is unlaoded. Then windows should assign a new, unused one on next driver load, like it normally does when the driver is loaded first time.

  • Hello,

    To implement such behavior (automatic com port assignment) in device driver does not solve all cases (ie. after the driver instalation (MyDevice on COM3) may someone manually re-configure any device to the same COM3, so there will be again 2 devices on COM3)

    Finally, it looks like I got a solution:

    1) enumerate through all devices (PORTS class)

    2) get list of duplicated devices (ie. devices configured to the same com port)

    3) are there any MyDevices in duplicated devices? If yes go to 4) otherwise there is no further work for me

    4) there is one or more MyDevice(s) in duplicated devices => Show dialog to user "MyDevice is assigned to com port which is already assigned to another device(s). It is highly recommended to change the com port for MyDevice. Do you want to change it now?". If yes, go to 5)

    5) for each MyDevice in duplicated devices do open windows dialog which will do the hard work (SerialDisplayAdvancedSettings in msports.dll)

    I do the procedure 1) -> 5) in my App before each opening connection to MyDevice

    I know this is not fully automatic solution, but the hard work is done by windows SerialDisplayAdvancedSettings dialog so I can be sure I will not miss something important  (in registers...). The user have to just select the available com port, that is all.

    I will also try to work with COM Port Database Support Routines so there is a chance I will change my mind :)

    Does anybody know possible issues using SerialDisplayAdvancedSettings dialog?

    Regards
    Vlastimil Petrucha

  • Vlastimil Petrucha said:
    To implement such behavior (automatic com port assignment) in device driver does not solve all cases (ie. after the driver instalation (MyDevice on COM3) may someone manually re-configure any device to the same COM3, so there will be again 2 devices on COM3)


    I was tlakign about doing this on driver loading. Then no-one can configure anothe rport as teh windows UI will refuse this (your driver is already occupying it).

    However, a different driver might be loaded after yours and isntall itself on the same COM port nr. There's nothing you can do to prevent this. (well, you could check, before picking a port, whether any other driver has this port assigned in the registry)

    But just detecting the issue and pointing the user to the solution is way better than what many others do (let the use find the cause for the trouble by himself :( ).

**Attention** This is a public forum