NI-Serial COM Ports are Enumerated out of Order on Windows 7

Updated Dec 23, 2023

Reported In

Driver

  • NI-Serial

Operating System

  • Windows

Issue Details

With NI Serial hardware on Windows 7, I notice that the COM ports are not enumerating in order. I would expect that the ports would be assigned COM numbers in the same order as the ports appear on the hardware. Port 1 on the hardware should have the lowest available COM number on the system and the COM ports should be assigned in port order.

Solution

Windows 7 parallelizes the COM port enumeration process causing the ports of newly installed hardware to be enumerated in a random order with our driver. After the first time the hardware is enumerated, the COM numbers are saved in the Windows registry. If the NI-Serial driver is not uninstalled or if the hardware is not placed in different slots, the hardware will continue to have the same COM numbers assigned between reboots. 

Upgrading to a later version of NI-Serial, performing a repair of NI-Serial, or uninstalling and reinstalling NI-Serial will cause the ports to re-enumerate. When this happens on Windows 7, the result will be that the ports enumerate out of order.

NiPortConfig.exe is a utility that allows you to manually assign a contiguous range of COM numbers to a board. It is located in the NI-Serial Installation Directory, which is C:\Program Files\National Instruments\NI-Serial on 32-bit operating systems and C:\Program Files (x86)\National Instruments\NI-Serial on 64-bit operating systems.  It is only included with the full version of the driver, it is not installed with the runtime.




To use the utility:
  1. Use the Select Serial Interface drop down box to select the hardware with the ports that are enumerated out of order.
  2. Use Select Starting COM Number drop down box to select the first COM number that should be used for this device.
  3. Be sure to use only COM numbers that are not already in use. The Select Starting COM Number drop down box will show if any ports are already used by other hardware on the system.
  4. Select Apply or OK to save the new COM numbers to the hardware.

Additional Information

This same parallelization can also cause a similar problem with multiple hardware interfaces being installed to Windows 7 at the same time. Multiple DAQ cards installed to identical systems into the identical slots will result in different device IDs getting assigned to the cards (Dev1, Dev2 etc.) because they are enumerated in parallel.