|
-
Jul 14th, 2011, 05:26 AM
#1
Thread Starter
New Member
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.
-
Jul 14th, 2011, 07:59 AM
#2
Re: App to View which COM port a USB-Serial device is connected to.
Do you only have Belkin USB to Serial Adapters?
-
Jul 14th, 2011, 08:32 AM
#3
Thread Starter
New Member
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.
-
Jul 14th, 2011, 09:20 AM
#4
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.
-
Jul 15th, 2011, 03:04 AM
#5
Thread Starter
New Member
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?
-
Jul 15th, 2011, 06:16 AM
#6
Re: App to View which COM port a USB-Serial device is connected to.
 Originally Posted by 11slayer11
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?
-
Jul 15th, 2011, 06:53 AM
#7
Thread Starter
New Member
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.
-
Jul 15th, 2011, 07:21 AM
#8
Re: App to View which COM port a USB-Serial device is connected to.
 Originally Posted by 11slayer11
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.
-
Jul 15th, 2011, 07:42 AM
#9
Thread Starter
New Member
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".
-
Jul 15th, 2011, 09:25 AM
#10
Re: App to View which COM port a USB-Serial device is connected to.
 Originally Posted by 11slayer11
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?
-
Jul 15th, 2011, 09:42 AM
#11
Thread Starter
New Member
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.
-
Jul 15th, 2011, 09:47 AM
#12
Re: App to View which COM port a USB-Serial device is connected to.
 Originally Posted by 11slayer11
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.
-
Jul 15th, 2011, 10:18 AM
#13
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
-
Jul 15th, 2011, 01:22 PM
#14
Junior Member
Re: App to View which COM port a USB-Serial device is connected to.
Branching off from the last post:
vb 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() Label1.Text = port & " is not connected" sp.Close() Catch ex As Exception Label1.Text = port & " is connected to a device") End Try Next
-
Jul 15th, 2011, 01:27 PM
#15
Re: App to View which COM port a USB-Serial device is connected to.
 Originally Posted by Farrow
Branching off from the last post:
vb 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()
Label1.Text = port & " is not connected"
sp.Close()
Catch ex As Exception
Label1.Text = port & " is connected to a device")
End Try
Next
All you will see in the label is the state of the last port if there is more than 1.
-
Jul 15th, 2011, 02:09 PM
#16
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|