Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I detect the comm port that is connected to a hardware using vc++?

Hi,
I am trying to detect the comm port, that the hardware is connected to, in my program before initialising it. What function can I use to do that? Can someone pls help me out? Thanks!
0 Kudos
Message 1 of 2
(2,831 Views)
HI,

There isn't a serial function that will allow you to automatically detect the hardware. Your program needs to test (probe) the serial ports in the system.

A simple way would be to open a COM port and send a command. The depending on the response (if any) you can determine that the hardware is connected. This assumes that the hardware will have a fix RS-232 configuration. Depending on how your instrument uses the port you can think of different ways to identify your hardware.

I think this is basically what the OS and device driver do on ISA and PCI buses to detect the PC devices (and implement PnP).

Hope this helps.
DiegoF
0 Kudos
Message 2 of 2
(2,831 Views)