Reputation: 933
I'm programming for Windows CE and I need to connect to a scanner. There is no problem - I know that it is on port COM0, but if I plug in another device earlier it gets another COM port... to get all com ports the easy way is:
SerialPort.GetPortNames()
But I don't know how to identify a device? Is there any standard way? I can't 'ping' it since there is one device that only sends data... it spams data all the time... and I don't know how to 'ping' a device...
Upvotes: 1
Views: 2226
Reputation: 45071
The problem of a serial connection is that is stateless. You can't know if anyone is on the other side listening or who is listening.
To find this out you just have a few choices:
AT
and you'll receive an OK
.So if you can't use any of the above methods you can't automatically detect which port to use. So the only working model is to ask the user for the correct setting(s) (e.g. ComboBox with available ports or BaudRates, CheckBoxes for the different boolean configuration settings, etc).
Upvotes: 4