01-14-2013 12:58 AM
i have a USB to UART cable , do somebody knowes how to get the description of com port , like we see in deveice managerment. ?
Solved! Go to Solution.
01-14-2013 07:29 AM
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.
01-14-2013 08:11 AM
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);
01-14-2013 08:16 PM
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 );
01-14-2013 11:57 PM
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.
01-15-2013 01:02 AM
thanks, at least my problem has been solve