Skip to content

Commit

Permalink
Small fix with reading the binary file
Browse files Browse the repository at this point in the history
It's always a good idea to actually close a file after you read one :)
  • Loading branch information
twatorowski committed Jul 18, 2015
1 parent a7901e8 commit 9dab1cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
13 changes: 6 additions & 7 deletions STM32 Flash Loader/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions STM32 Flash Loader/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ private async void bWrite_Click(object sender, EventArgs e)
bin = new byte[s.Length];
/* read file contents */
await s.ReadAsync(bin, 0, bin.Length);
/* close file */
s.Close();
/* error during read? */
} catch (Exception) {
/* set message */
Expand Down Expand Up @@ -140,8 +142,11 @@ await stb.WriteMemory(address, bin, 0, bin.Length, p,
} finally {
/* close port */
stb.Close();

/* re-enable button */
bWrite.Enabled = true;
/* set focus */
bWrite.Focus();
}
}

Expand All @@ -167,16 +172,6 @@ private void cbBauds_SelectedIndexChanged(object sender, EventArgs e)
baudRate = uint.Parse((string)cbBauds.SelectedItem);
}

/* set focus if button was enabled */
private void bWrite_EnabledChanged(object sender, EventArgs e)
{
/* button was enabled?*/
if (bWrite.Enabled) {
/* set focus */
bWrite.Focus();
}
}

/* parse address */
private void tbAddress_Leave(object sender, EventArgs e)
{
Expand Down Expand Up @@ -240,7 +235,8 @@ private void UpdateStatus(bool ding, string text)

private void cbPorts_KeyDown(object sender, KeyEventArgs e)
{
cbPorts.DroppedDown = true;

//cbPorts.DroppedDown = true;
}
}
}

0 comments on commit 9dab1cd

Please sign in to comment.