Skip to content

Commit

Permalink
Fix exception when with less than five serial ports (ArduPilot#3265)
Browse files Browse the repository at this point in the history
  • Loading branch information
EosBandi authored Jan 12, 2024
1 parent 196958a commit fb6af04
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions GCSViews/ConfigurationView/ConfigSerial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public partial class ConfigSerial : MyUserControl, IActivate, IDeactivate

private bool _gotUARTNames = false;
private bool _gotOptionRules = false;
private int serialPorts = 0;
private Dictionary<int, string> _uartNames = new Dictionary<int, string>();
private Dictionary<int,SerialOptionRuleItem> _optionRules = new Dictionary<int, SerialOptionRuleItem>();

Expand Down Expand Up @@ -160,7 +161,7 @@ public void Activate()
}

//find the largest numbered serialx_baud param
int serialPorts = 0;
serialPorts = 0;
foreach (var param in MainV2.comPort.MAV.param.Keys)
{
if (param.StartsWith("SERIAL") && param.EndsWith("_BAUD"))
Expand Down Expand Up @@ -408,7 +409,7 @@ private void doApplyRules(string portName, string v)
//But this includes the USB port, so we can only have 4 ports set to mavlink

int mavlinkPorts = 0;
for (int i = 1; i <= 5; i++)
for (int i = 1; i <= serialPorts; i++)
{
string protParamName = "SERIAL" + i.ToString() + "_PROTOCOL";
if (MainV2.comPort.MAV.param[protParamName].Value.ToString() == "1"
Expand Down

0 comments on commit fb6af04

Please sign in to comment.