LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Enumerating COM port in CVI programming

Hi,

Using VISA can find the hardware resources. I'd like to know excepting VISA, is there any way to do this?


David

0 Kudos
Message 1 of 4
(4,001 Views)
I imagine you should find some informations deeply digging inside the registry or SDK functions provided you know how to search, which I don't know.
Maybe the simplest thing at all it to try opening the com ports in a loop and monitor the resulting error code: this operation should take only a few seconds to perform since you are not actually performing any I/O operation on the ports in this moment.


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 2 of 4
(3,991 Views)
I have used the loop method for years. Here is part of my code.
 
comstring is defined as a 2 dimensional string array of the ports so that comstring[1]="COM1",comstring[2]=COM2", thru "COM32". portarray[ ] is an integer array, size 33. When the loop is done portarray[x] will contain 1 if COMx exists on the PC, 0 if it does not.
 
        for(i=1;i<33;i++)
            {
            comstatus=OpenComConfig (i, comstring[i], 9600, 0, 8, 1, 512, 512);
            if (comstatus!=0)
                {
                //FAILED
                portarray[i]=0;
                }
            else
                {
                //OPENED
                portarray[i]=1;
                }
            CloseCom(i);
            }
0 Kudos
Message 3 of 4
(3,986 Views)
It's not very easy to do in CVI. I have written a DLL that you can use to find all the COM ports in a system (or ones with particular names). You will find it in this thread.
--
Martin
Certified CVI Developer
0 Kudos
Message 4 of 4
(3,972 Views)