Hello.
My question is as follows:
I am making a little gui that uses COMPORTS to connect to a board. I want the program to be able to find the correct COMPORT by itself. This goes fine with try/catch as long as I dont have other devices that uses COMPORTS. My code so far is as follows:
This doesn't work when I have an other device using a lower COMPORT as the one for my gui. If I open device manager I can see different desciptions of the comports. The one I want to use is described as:
"USB Serial Port (COM3)"
Do you guys know a way to return this description so I can do a "chec" to see wheater I have selected the right COMPORT?
Thanks allready!
/Aske
My question is as follows:
I am making a little gui that uses COMPORTS to connect to a board. I want the program to be able to find the correct COMPORT by itself. This goes fine with try/catch as long as I dont have other devices that uses COMPORTS. My code so far is as follows:
Code:
public void InitSerialPort()
{
int i = 0;
bool comportSelect = false;
while (comportSelect == false)
{
try
{
if (i == 21)
{
Error(0);
comportSelect = true;
}
else
{
mySerialPort = new SerialPort(("COM" + i.ToString()), 19200, Parity.None, 8, StopBits.Two);
mySerialPort.DataReceived += new SerialDataReceivedEventHandler(Received);
mySerialPort.Open();
mySerialPort.
MessageBox.Show(mySerialPort.PortName);
comportSelect = true;
}
}
catch
{
i++;
}
}
}
This doesn't work when I have an other device using a lower COMPORT as the one for my gui. If I open device manager I can see different desciptions of the comports. The one I want to use is described as:
"USB Serial Port (COM3)"
Do you guys know a way to return this description so I can do a "chec" to see wheater I have selected the right COMPORT?
Thanks allready!
/Aske
Comment