Skip to content

Commit 1493366

Browse files
Adding a loop counter to ETSerialManager to limit the scanning to 5 attempts
Fixes #334
1 parent eb56a26 commit 1493366

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Buttplug.Server.Managers.ErosTek/ETSerialManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ private void ScanSerialPorts(string[] selectedComPorts)
4040
{
4141
string[] comPortsToScan;
4242
_isScanning = true;
43+
var count = 5;
4344

44-
while (_isScanning)
45+
while (_isScanning && count-- > 0)
4546
{
4647
// Enumerate Ports
4748
if (selectedComPorts == null || selectedComPorts.Length == 0)
@@ -148,6 +149,12 @@ private void ScanSerialPorts(string[] selectedComPorts)
148149
// _isScanning = false; // Uncomment to disable continuuous serial port scanning
149150
}
150151

152+
if (count < 0)
153+
{
154+
BpLogger.Info("Automatically Stopping Scanning Serial Ports for ErosTek Devices");
155+
}
156+
157+
_isScanning = false;
151158
InvokeScanningFinished();
152159
}
153160
}

0 commit comments

Comments
 (0)