detect USB cable connected to USB port???
-
Hi all, Is there any method by which i can find out if a USB cable is connected to USB port through VB program. It would of great help if someone can guide me with this. Thanx in advance, sushma
A cable?? No there isn't. The USB hub doesn't even know that the cable is there, so how is your code going to figure it out? Devices on the other hand... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
A cable?? No there isn't. The USB hub doesn't even know that the cable is there, so how is your code going to figure it out? Devices on the other hand... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
thanx so much for responding to my post. i cant even figure out if the USB port is empty? i will tell u in detail what i am supposed to do in my program. ->There are two options in my GUI, Serial Port or USB port. Depending on which port the user selects i must transmit data through that port. -> If the user selects Serial port it is pretty simple as even the COM port will be selected by the user. -> As i had mentioned longback that i am using "USB to RS232 converter" which makes USB port look like a COM port and some COM port number(other than the available physical ports) will be allocated to USB port by the software. ->If USB is selected by the user then i must be able to display an error if the cable is not connected and the user is trying to communicate through that. -> Usually the last valid port will be the COM port allocated to USB port by the software(USB to RS232 converter). The COM port will be allocated to USB port only after a USB cable is plugged in to the USB port. -> In my program i will be finding out the last valid port available and that port i will be using for communicating through USB.In case if the USB cable is not plugged in then i will assume someother physical port as the one allocated for USB port.To avoid this error i must find a method by which i can find out what is the COM port number allocated by the software to USB. I am not able to find any method for this :confused: . So i thought it will be better if i am atleast able to find out whether USB port is plugged in with a USB cable:~ Hope you got what is my problem:(
-
thanx so much for responding to my post. i cant even figure out if the USB port is empty? i will tell u in detail what i am supposed to do in my program. ->There are two options in my GUI, Serial Port or USB port. Depending on which port the user selects i must transmit data through that port. -> If the user selects Serial port it is pretty simple as even the COM port will be selected by the user. -> As i had mentioned longback that i am using "USB to RS232 converter" which makes USB port look like a COM port and some COM port number(other than the available physical ports) will be allocated to USB port by the software. ->If USB is selected by the user then i must be able to display an error if the cable is not connected and the user is trying to communicate through that. -> Usually the last valid port will be the COM port allocated to USB port by the software(USB to RS232 converter). The COM port will be allocated to USB port only after a USB cable is plugged in to the USB port. -> In my program i will be finding out the last valid port available and that port i will be using for communicating through USB.In case if the USB cable is not plugged in then i will assume someother physical port as the one allocated for USB port.To avoid this error i must find a method by which i can find out what is the COM port number allocated by the software to USB. I am not able to find any method for this :confused: . So i thought it will be better if i am atleast able to find out whether USB port is plugged in with a USB cable:~ Hope you got what is my problem:(
In that case, don't worry about the USB cable being plugged in. Since your app is communicating over Serial ports only, no matter what the cable medium is, your app doesn't change if the cable changes. So why are you complicating your code over something your code doesn't care about in the first place? There is nothing that maps COM ports to what cable they're on, if they are simulated, or implemented on hardware other than actual Serial ports. The driver you installed for the cable puts up the illusion of a Serial port, then quietly sits behind it, translating between serial comm and USB. If the USB cable can be on any COM port, don't mess with USB. Just go through the COM ports and try to communicate with your target app on each one. If you get a response, you've found the port your need. If not, you'll have to rely on the user to tell you which port to use. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome