-
Comport or Ethernet?
Dear Experts,
I am programming a software for a hardware interfaced using either the comport or the ethernet.
I am now specifying in my software whether the harware device has to be connected using comport or the ethernet and then i am clicking on connect button to connect to the machine. And if the software finds that the machine is not connected with the specified connection then it gives an error message.
But what i want to do is.... When i click on Connect Machine button, then my software should automatically search for, which connection the machine is being connected and then connect using that perticular connection. How can i do this?
Please help with this query.....
-
Re: Comport or Ethernet?
-
Re: Comport or Ethernet?
When you say "ethernet", what do you mean? Does the device have an IP address if it is connected that way, or is there a different protocol in use? If you have a fixed IP address, that would probably be the easiest way to start, as you would try the address, and if that doesn't work, then go for the COM ports.
I haven't done it in years, but you can enumerate the COM ports on the system, and if you have some means to test one, as it sounds like you do, then you could iterate through all of them testing each one to see if the device is there. In my experience, programs that do this are not 100% reliable, so you would probably want some other manual means as a backup.
If that sounds like a way to go, and nobody else posts something sooner, I can look up how I enumerated COM ports. I don't have it on this computer.
-
Re: Comport or Ethernet?
this will get you each serial port name
For Each sn As String In IO.Ports.SerialPort.GetPortNames()
Next
ethernet will be faster.