03-12-2014 08:08 AM
How can I find the comport number assigned to a usb comport using cvi. I need to test six (6) devices using usb comports and need to either permanently set the comport numbers in windows or have CVI dynamically find the devices by serial number and obtain the windows comport assignment. Does anyone have an example program that performs this task?
03-12-2014
08:49 AM
- last edited on
06-09-2025
12:34 PM
by
Content Cleaner
What hardware drivers are you using to interface with the USB comport devices? This will determine how to communicate with your devices.
If you are using NI-VISA, there is an example available for searching all VISA resources: Finding VISA Resources Using LabWindows/CVI. Below is a screenshot of a function in the example code:
03-12-2014 11:04 AM
Another option is to try poking around in the registry. If you know the USB device's Vendor ID (VID) and Product ID (PID) you can find the device information in the registry under HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_XXXX&PID_YYYY where XXXX is the VID and YYYY is the PID. If you don't know the VID and PID you can find them in the device's properties in Device Manager. In the registry key you'll find a subkey for each unique device's serial number. You can try poking around in there to see if there is a subkey that has the COM port number. Given that, you can use the Windows Registry functions in the Programmer's toolbox to read the registry key and obtain the COM port number. Hope this helps.
03-19-2014 06:52 AM
I tried the code. It returns the following:
ASRL1::INSTR
ASRL2::INSTR
ASRL4::INSTR
ASRL10::INSTR
Under Windows Device manager I have the following ports
Communications Port (COM1)
ECP Printer Port (LPT1)
Silicon Labs CP210x USB to Uart Bridge (COM4)
The Device hardware ID is
USB\VID_10C4&PID_EA60&REV_0100
USB\VID_10C4&PID_EA60
Device Description
Silicon Labs CP210x USB to UART Bridge
I plan on connecting six (6) of these usb devices to a test fixture that will be connected to multiple PC's. I need the software to identifiy the USB device by its unique serial number and obtain the comport number for that device. Any suggestions?
03-19-2014
09:30 AM
- last edited on
06-09-2025
12:35 PM
by
Content Cleaner
You actually need to configure NI-VISA to recognize your USB devices. I wasn't sure if you were doing that already. Here is a tutorial on using NI-VISA hardware driver with USB devices: USB Instrument Control Tutorial
Are you using any other hardware drivers to communicate with or control your USB devices?