LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the description of COM port

Solved!
Go to solution

i have a USB to UART cable ,  do somebody knowes how to get the description of com port , like we see in deveice managerment. ?

 

device.JPG

0 Kudos
Message 1 of 6
(3,407 Views)

IIRC, the description in the device manager is for when you use "type file >COM1:" in a terminal. When you use it in C you have to open it with the parameters you want, there's no default.

0 Kudos
Message 2 of 6
(3,397 Views)
Solution
Accepted by topic author Gerryli

You should be able to get this valua with VISA:

#include <visa.h>
static ViSession sessH; static ViSession visaH; static ViChar descr[512]; viOpenDefaultRM (&sessH); viOpen (sessH, "ASRL1::INSTR", VI_NULL, VI_NULL, &visaH); viGetAttribute (visaH, VI_ATTR_INTF_INST_NAME, descr); viClose (visaH); viClose (sessH);

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 6
(3,393 Views)

Dear Roberto

 

appricate for you help , indeed, i sucess get the drscription what i want. however,  i am not familiar with Visa, is there a function can help to enum the existing COM port, ?  currently, i am using the windows API to access the register to get the COM port in the system.

 

 

 rtn = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Hardware\\DeviceMap\\SerialComm",   
           0, KEY_READ, &hKey); // 打开串口注册表  
   if( rtn == ERROR_SUCCESS)   
   {   
     int i=0;   
     char portName[256],commName[256];   
     DWORD dwLong,dwSize;   
     while(1)   
 		{   
       dwSize = sizeof(portName);   
       dwLong = dwSize;  
       rtn = RegEnumValue( hKey, i, portName, &dwLong,   
       NULL, NULL, (PUCHAR)commName, &dwSize );  
  

 

123.JPG

0 Kudos
Message 4 of 6
(3,381 Views)

I too am not familiar with VISA but you should be able to enumerate resources following the examples in chapter 4 in VISA manual (this document dates back in 2001: you should have the copy that matches your actual release of VISA on your machine). Example 4.2 lists all available VXI resources, but you can adapt it to serial devices using the apprpriate regular expression detailed a few pages after that.

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 5 of 6
(3,377 Views)

thanks, at least my problem has been solve Smiley Happy

0 Kudos
Message 6 of 6
(3,373 Views)