LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting a usb comport by serial number

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?

0 Kudos
Message 1 of 5
(7,779 Views)

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:

 

Find VISA Resources.PNG

Taylor B.
National Instruments
0 Kudos
Message 2 of 5
(7,771 Views)

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.

0 Kudos
Message 3 of 5
(7,762 Views)

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?

 

0 Kudos
Message 4 of 5
(7,698 Views)

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?

Taylor B.
National Instruments
0 Kudos
Message 5 of 5
(7,685 Views)