Checking if hardware is connected
Hi all VB expert,
I have a problem with COM port connection problem. I try to look up a help from any VB forum, but I still can't find a solution. All the forum I found, just teach me how to detect the serial port available in the PC, but not testing on whether the port is connected with hardware. Is that possible to do? Please help. Thanks
Re: Checking if hardware is connected
Is that mean there are no solution for this problem? Why no body can help me here? :confused:
Re: Checking if hardware is connected
Whether it's possible to detect whether your hardware is connected depends on what the hardware is. You can detect some hardware, but there's hardware you can't detect. What kind of hardware are you trying to detect?
Re: Checking if hardware is connected
Actually, What I am try to do is checking whether the port is not connected, then I will try to let the user know that hardware (ie. barcode reader) is not exist. Using mscomm.portopen just tell me that I have a serial port 'COM1' in my computer, but not checking whether the port is connecting to the hardware or not.
Re: Checking if hardware is connected
Check the documentation for the reader - see if it will respond to any particular input. For example, a Hayes-compatible modem will respond to "ATI" with a certain string. If the reader does something like that, send the string it responds to and look for the proper response while a timer is running. If the timer times out (set it for twice as long or three times as long as it normally takes for the reader to respond), there's no reader connected.
If there's no string the reader will respond to, and it doesn't set any of the handshake lines, there's no way to tell if it's connected. (If it sets handshake lines you can tell that something is connected by checking the status bits, but you can't tell what the connected hardware is.)
Re: Checking if hardware is connected
You can check the DSR and CTS lines, if a harware device is connected to the COMM-port.
Re: Checking if hardware is connected
IF the device does any handshaking. Quite a few serial devices don't.
Re: Checking if hardware is connected
Quote:
Originally Posted by namrekka
You can check the DSR and CTS lines, if a harware device is connected to the COMM-port.
Thank you very much, you have solve my problem. :thumb: