Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. detect USB cable connected to USB port???

detect USB cable connected to USB port???

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sushmadm
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • S Sushmadm

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        S Offline
        S Offline
        Sushmadm
        wrote on last edited by
        #3

        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:(

        D 1 Reply Last reply
        0
        • S Sushmadm

          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:(

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups