Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Find a virtual COM Port

Status
Not open for further replies.

mhamini

Member level 1
Joined
Aug 23, 2005
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Iran-Tehran
Activity points
1,690
I have a board that communicates with my computer thru the USB and it appears on my computer as a virtual com port. I am trying to make an existing MFC program that I made work with the board. I have code in my program that goes through the com ports to find and list all the available com ports. The code looks like this:
char sPort [6] = "COMX";
for (int index = 0; index < 16; index++) // Find available Com Ports
{
HANDLE hPort = INVALID_HANDLE_VALUE;
sprintf(sPort, "COM%i", index+1);
hPort = CreateFile (sPort,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
if ( INVALID_HANDLE_VALUE != hPort)
{
// port exists...
m_ctlComPortBox.AddString(sPort); // Add available Com Port to IDC_ANISETTING_COMPORT
CloseHandle ( hPort);
}
}
The problem is, that it isn't finding the virtual Com ports. Are there changes that I can do to make it detect the virtual ports or is there another method that might work? By the way, my board is coming up as com 13 if that means anything.
 

I have been strugeling with enumeration of COM ports on windows for several days. The only way to do it properly is working with the registry. There are several articles on www.codeproject.com that describes more in detail different aproaches on how to do this. One problem is also that the register and how windows uses it is different depending on the windows version and there needs to be diferent implementations for win95, win98, win nt4 and win 2k/xp

Check this articles for more info on how to start...
**broken link removed**
https://www.codeproject.com/system/enumports.asp
https://www.codeproject.com/system/setupdi.asp
https://www.codeproject.com/system/listports.asp

I cannot realy recomende any one of them, at least for me none of the worked "out of the box" without problems, but they where a great source of info when I did my own implementation...

re me
 

    mhamini

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top