i want to detect/Configure serial port (COM Port) on which my device is connected automatically. Is it possible to do so in c#?
-
You have to detect COM numberASalameh– ASalameh2014-07-20 12:16:46 +00:00Commented Jul 20, 2014 at 12:16
-
thanks, yes but how do i do it programmatic automated ? I need to set Com port number, Boud rate n all things that I wanna detect programatically automatedSwarup– Swarup2014-07-20 12:18:51 +00:00Commented Jul 20, 2014 at 12:18
-
Maybe this helpASalameh– ASalameh2014-07-20 12:20:59 +00:00Commented Jul 20, 2014 at 12:20
-
Nothing is "automatic" when you use serial ports. Dating from the stone-age of computing, they are not plug & play devices. You have to know the port number and the port settings, like baudrate, up front and they must exactly match the device settings. You typically need to provide the user with a configuration UI or file so they can match your program to the device.Hans Passant– Hans Passant2014-07-20 12:32:40 +00:00Commented Jul 20, 2014 at 12:32
-
Will the device respond automatically when connected?dbasnett– dbasnett2014-07-20 14:18:58 +00:00Commented Jul 20, 2014 at 14:18
|
Show 3 more comments
1 Answer
What exactly you like to do? Did you look at Properties and Methods in System.IO.Ports class?
Following MSDN article may help.
http://msdn.microsoft.com/en-us/library/system.io.ports.serialport(v=vs.110).aspx
2 Comments
Swarup
I am going to read data from serial port given by my electronic device which i am going to connect. But i need to configure each time manually within my program. I got all config details from system.IO.Ports but i am not getting automate config...
Haja Maideen
You must convert your app as multi threaded and a function which runs in background thread, and poll all the com ports in the system and try to open and handshake each. What ever port open successfully with out timeout, and able to handshake with you, it is the port you are interested and device connected to it. Then you can raise an event, from this background function which is nothing but the autodetect.