Application now searches for working comport
This commit is contained in:
@@ -74,7 +74,13 @@ namespace ErgometerApplication
|
||||
if (SerialPort.GetPortNames().Length > 0)
|
||||
{
|
||||
string error = "";
|
||||
bool connect = MainClient.Connect(SerialPort.GetPortNames()[0], username, password, out error);
|
||||
bool connect = false;
|
||||
foreach(string comport in SerialPort.GetPortNames())
|
||||
{
|
||||
connect = MainClient.Connect(comport, username, password, out error);
|
||||
if (connect)
|
||||
break;
|
||||
}
|
||||
|
||||
if (connect)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,8 @@ namespace ErgometerLibrary
|
||||
comPort.Parity = Parity.None;
|
||||
comPort.StopBits = StopBits.One;
|
||||
comPort.BaudRate = 9600;
|
||||
comPort.ReadTimeout = 1500;
|
||||
comPort.ReadTimeout = 200;
|
||||
comPort.WriteTimeout = 350;
|
||||
try {
|
||||
comPort.Open();
|
||||
}
|
||||
@@ -54,7 +55,15 @@ namespace ErgometerLibrary
|
||||
{
|
||||
if (IsOpen())
|
||||
{
|
||||
comPort.WriteLine(input);
|
||||
|
||||
try
|
||||
{
|
||||
comPort.WriteLine(input);
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user