private void updateFirmwareToolStripMenuItem_Click(object sender, EventArgs e) { toolStripProgressBar1.Style = ProgressBarStyle.Continuous; this.toolStripStatusLabel1.Text = ""; OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "*.hex|*.hex"; if (ofd.ShowDialog() == DialogResult.OK) { byte[] FLASH; try { toolStripStatusLabel1.Text = "Reading Hex File"; statusStrip1.Refresh(); IntelHex hex = new IntelHex(); hex.Load(ofd.FileName); FLASH = hex.RawData; } catch { MessageBox.Show("Bad Hex File"); return; } toolStripStatusLabel1.Text = "Rebooting"; bool fail = false; //ArduinoSTK sp; toolStripStatusLabel1.Text = "Rebooting"; MegaLoad sp = new MegaLoad(); toolStripProgressBar1.Maximum = 100; toolStripProgressBar1.Style = ProgressBarStyle.Continuous; toolStripProgressBar1.Value = 0; sp.Progress += sp_Progress; sp.Connected += (s, ce) => { toolStripStatusLabel1.Text = "Programming"; }; try { osdPort.PortName = CMB_ComPort.Text; osdPort.Open(); osdPort.Reboot(); osdPort.Close(); sp.PortName = CMB_ComPort.Text; sp.BaudRate = bootRate; sp.WriteBufferSize = 32; sp.ReadTimeout = 5000; sp.Open(); } catch { MessageBox.Show("Error opening com port", rmMessages.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } toolStripStatusLabel1.Text = "Connecting"; //sp.ReadExisting(); fail = !sp.Upload(FLASH, null); sp.Close(); if (!fail) { toolStripStatusLabel1.Text = "Program Done"; } else { toolStripStatusLabel1.Text = "Program Failed"; } } }