Skip to content

Commit

Permalink
added serial connection manager retry
Browse files Browse the repository at this point in the history
(cherry picked from commit 9370420)
  • Loading branch information
ctacke committed Sep 29, 2023
1 parent 2cd34ba commit ca0ad09
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Source/v2/Meadow.Cli/MeadowConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,23 @@ public MeadowConnectionManager(ISettingsManager settingsManager)
}
else
{
_currentConnection = new SerialConnection(route);
var retryCount = 0;

get_serial_connection:
try
{
_currentConnection = new SerialConnection(route);
}
catch
{
retryCount++;
if (retryCount > 10)
{
throw new Exception($"Cannot find port {route}");
}
Thread.Sleep(500);
goto get_serial_connection;
}
}

return _currentConnection;
Expand Down

0 comments on commit ca0ad09

Please sign in to comment.