Results 1 to 16 of 16

Thread: App to View which COM port a USB-Serial device is connected to.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Location
    Basement, UK
    Posts
    6

    Post App to View which COM port a USB-Serial device is connected to.

    Hi All,

    I am currently having an issue finding information on how to develop a simple application that a user can run to find out which COM port ie. COM1, COM2, ect is assined to the Belkin USB to Serial Adapters we use in the company.

    To anyones knowledge is this possible and how would I implement it in a Windows Form Application.

    Please ask for more info if required.

    Thanks in advance.

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    Do you only have Belkin USB to Serial Adapters?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Location
    Basement, UK
    Posts
    6

    Re: App to View which COM port a USB-Serial device is connected to.

    That's right,
    They are all the same Version and type.

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    This

    Code:
            Dim myPorts() As String = IO.Ports.SerialPort.GetPortNames
    will get the names of the ports that the system knows about.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Location
    Basement, UK
    Posts
    6

    Re: App to View which COM port a USB-Serial device is connected to.

    I have done this and it will show a list of COM Ports. I already have such a code...

    For Each sp As String In My.Computer.Ports.SerialPortNames
    ListBox2.Items.Add(sp)
    Next

    Any other Ideas for finding out which port the Belkin Device is assigned too?

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    Quote Originally Posted by 11slayer11 View Post
    I have done this and it will show a list of COM Ports. I already have such a code...

    For Each sp As String In My.Computer.Ports.SerialPortNames
    ListBox2.Items.Add(sp)
    Next

    Any other Ideas for finding out which port the Belkin Device is assigned too?
    So you have other serial ports that aren't Belkin?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Location
    Basement, UK
    Posts
    6

    Re: App to View which COM port a USB-Serial device is connected to.

    No,

    The code provided displays the COM ports 1,2,3 ect and im looking for a way to display which COM port the USB to Serial device has been assigned as this can change when the PC is shut down and then restarted.

    I just want a one button app that will display the COM port that has been assigned or a set of COM ports with connected devices...

    If this is even possible.

  8. #8
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    Quote Originally Posted by 11slayer11 View Post
    No,

    The code provided displays the COM ports 1,2,3 ect and im looking for a way to display which COM port the USB to Serial device has been assigned as this can change when the PC is shut down and then restarted.

    I just want a one button app that will display the COM port that has been assigned or a set of COM ports with connected devices...

    If this is even possible.
    Are you looking for the one, of potentially many, belkin serial ports that are connected to some other device? I am confused.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Location
    Basement, UK
    Posts
    6

    Re: App to View which COM port a USB-Serial device is connected to.

    I am only looking for one as there will only be one USB to Serial Adapter in use at any one time.

    1.The USB to Serial adapter will be connected to the laptop.
    2.The Laptop (Windows) will assign a COM port to the Serial adapter.

    What the Application needs to do is find which COM port has been assigned to the adapter. So if COM1 has been assigned to the belikin adapter is should show "Belkin Adapter has been attached to COM1".

  10. #10
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    Quote Originally Posted by 11slayer11 View Post
    I am only looking for one as there will only be one USB to Serial Adapter in use at any one time.

    1.The USB to Serial adapter will be connected to the laptop.
    2.The Laptop (Windows) will assign a COM port to the Serial adapter.

    What the Application needs to do is find which COM port has been assigned to the adapter. So if COM1 has been assigned to the belikin adapter is should show "Belkin Adapter has been attached to COM1".
    So why can't you use the code?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  11. #11

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Location
    Basement, UK
    Posts
    6

    Re: App to View which COM port a USB-Serial device is connected to.

    I have but it doesn't show me what the COM port that the Belkin device is connected too. It just lists 3 different COM ports (COM3, COM4, COM1).

    I need it so a user can see that COM port <1, 2 or 3 ect> is definately assigned to the USB to Serial Belkin adapter so they can then go on and Hyperterminal in to a device.

  12. #12
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    Quote Originally Posted by 11slayer11 View Post
    I have but it doesn't show me what the COM port that the Belkin device is connected too. It just lists 3 different COM ports (COM3, COM4, COM1).

    I need it so a user can see that COM port <1, 2 or 3 ect> is definately assigned to the USB to Serial Belkin adapter so they can then go on and Hyperterminal in to a device.
    Re-read post #6 and #7 and you will see my confusion.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  13. #13
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    I am guessing now:

    Code:
            Dim sp As New IO.Ports.SerialPort
            Dim pn() As String = IO.Ports.SerialPort.GetPortNames
            For Each port As String In pn
                Try
                    sp.PortName = port
                    sp.Open()
                    Debug.WriteLine(port & " is available")
                    sp.Close()
                Catch ex As Exception
                    Debug.WriteLine(port & " is not available")
                End Try
            Next
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  14. #14
    Junior Member
    Join Date
    Jun 2011
    Posts
    28

    Re: App to View which COM port a USB-Serial device is connected to.

    Branching off from the last post:
    vb Code:
    1. Dim sp As New IO.Ports.SerialPort
    2.         Dim pn() As String = IO.Ports.SerialPort.GetPortNames
    3.         For Each port As String In pn
    4.             Try
    5.                 sp.PortName = port
    6.                 sp.Open()
    7.                 Label1.Text = port & " is not connected"
    8.                 sp.Close()
    9.             Catch ex As Exception
    10.               Label1.Text = port & " is connected to a device")
    11.             End Try
    12.         Next

  15. #15
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: App to View which COM port a USB-Serial device is connected to.

    Quote Originally Posted by Farrow View Post
    Branching off from the last post:
    vb Code:
    1. Dim sp As New IO.Ports.SerialPort
    2.         Dim pn() As String = IO.Ports.SerialPort.GetPortNames
    3.         For Each port As String In pn
    4.             Try
    5.                 sp.PortName = port
    6.                 sp.Open()
    7.                 Label1.Text = port & " is not connected"
    8.                 sp.Close()
    9.             Catch ex As Exception
    10.               Label1.Text = port & " is connected to a device")
    11.             End Try
    12.         Next
    All you will see in the label is the state of the last port if there is more than 1.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  16. #16
    Junior Member
    Join Date
    Jun 2011
    Posts
    28

    Re: App to View which COM port a USB-Serial device is connected to.

    Yes, but that is really the only way I could think of :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width