|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Find COM device connectedHi,
I would like to make a win service that test all the com ports and find the deviced connected. Some device have some commands that return data. How can I make this test? Hi,
You would have to know what commands to send, and what responses to look for. There is nothing standard about this, so there cannot be any "one" answer. For example, if you wanted to detect if a modem is connected, you could send the string: "ATE1V1Q0" & vbCr 'VB .NET Then wait for the modem (or similar device) to respond with a reply that includes, but may not be limited to: "OK" & vbCrLf Other types of serial devices will work quite differently, so one cannot generally say what commands and responses will work. Dick -- Richard Grier, MVP Hard & Software Author of Visual Basic Programmer's Guide to Serial Communications, Fourth Edition, ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March 2006. See www.hardandsoftware.net for details and contact information.
Show quote
On 3 Apr, 19:00, "Dick Grier" <dick_grierNOSPAM@.msn.com> wrote: Yes but how to enumerate all COM device connected?> Hi, > > You would have to know what commands to send, and what responses to look > for. There is nothing standard about this, so there cannot be any "one" > answer. For example, if you wanted to detect if a modem is connected, you > could send the string: > > "ATE1V1Q0" & vbCr 'VB .NET > > Then wait for the modem (or similar device) to respond with a reply that > includes, but may not be limited to: > > "OK" & vbCrLf > > Other types of serial devices will work quite differently, so one cannot > generally say what commands and responses will work. > > Dick > > -- > Richard Grier, MVP > Hard & Software > Author of Visual Basic Programmer's Guide to Serial Communications, Fourth > Edition, > ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March > 2006. > Seewww.hardandsoftware.netfor details and contact information. Hi,
Use the PortNames method. I have an example on my website, though it only uses PortNames to fill a listbox for selection. Open each port in the array of names returned, and test them "one-at-a-time." Dick -- Richard Grier, MVP Hard & Software Author of Visual Basic Programmer's Guide to Serial Communications, Fourth Edition, ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March 2006. See www.hardandsoftware.net for details and contact information. |
|||||||||||||||||||||||