Skip to content

Commit

Permalink
Default TimeoutForFirmwareUpdate to Timeout (#1839)
Browse files Browse the repository at this point in the history
* Default `TimeoutForFirmwareUpdate` to `Timeout`
Fixes #1838
  • Loading branch information
neilenns authored Nov 21, 2024
1 parent 2a9ce03 commit 29ef81e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion MobiFlight/Board.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public class Connection
/// <summary>
/// Number of milliseconds to wait for the firmware update to complete before attempting to call GetInfo on the board.
/// </summary>
public int TimeoutForFirmwareUpdate = 15000;
public int TimeoutForFirmwareUpdate;
}

/// <summary>
Expand Down Expand Up @@ -414,6 +414,23 @@ public void Migrate()
Info.FirmwareExtension = "hex";
}
}

// Issue 1838:
// Handle undefined TimeoutForFirmwareUpdate by setting it to the value for Timeout.
if (Connection.TimeoutForFirmwareUpdate == 0)
{
// This test is required to ensure AvrDudeSettings actually exists. It may not, for example when
// loading a board.json file for something like a Pico.
if (AvrDudeSettings != null)
{
Connection.TimeoutForFirmwareUpdate = AvrDudeSettings.Timeout != 0 ? AvrDudeSettings.Timeout : 15000;
}
else
{
Connection.TimeoutForFirmwareUpdate = 15000;
}
}

}
#pragma warning restore CS0612 // Type or member is obsolete

Expand Down

0 comments on commit 29ef81e

Please sign in to comment.