private void btnBurn_Click(object sender, EventArgs e) { if (ProjectBuilder.CheckForWinAVR()) { owner.BurnerPanel.FormToProj(); System.Diagnostics.Process p = new System.Diagnostics.Process(); ProjectBuilder.SetEnviroVarsForProc(p.StartInfo); p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = "/k avrdude "; string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, owner.Project); p.StartInfo.Arguments += String.Format("-c {0} -p {1} {2} {3} {4}", owner.Project.BurnProgrammer, owner.Project.BurnPart, overrides, owner.Project.BurnOptions, GetArgString(fuseVal)); try { p.Start(); } catch (Exception ex) { ErrorReportWindow.Show(ex, "Error While Writing Fuse"); } } }
private void btnInteractive_Click(object sender, EventArgs e) { burnerPanel.FormToProj(); if (ProjectBuilder.CheckForWinAVR()) { System.Diagnostics.Process p = new System.Diagnostics.Process(); ProjectBuilder.SetEnviroVarsForProc(p.StartInfo); p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = "/k avrdude "; string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, project); p.StartInfo.Arguments += String.Format("-c {0} -p {1} {2} {3} -t", project.BurnProgrammer, project.BurnPart, overrides, project.BurnOptions); p.Start(); } }
private int ReadFuse() { if (ProjectBuilder.CheckForWinAVR()) { owner.BurnerPanel.FormToProj(); System.Diagnostics.Process p = new System.Diagnostics.Process(); ProjectBuilder.SetEnviroVarsForProc(p.StartInfo); p.StartInfo.FileName = "avrdude"; p.StartInfo.Arguments = ""; //p.StartInfo.FileName = "cmd"; //p.StartInfo.Arguments = "/k avrdude"; string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, owner.Project); string avrdudeFuseStr = GetAVRDUDEFuseStringFromType(typeOfFuse); string action = String.Format("-U {0}:r:\"{1}\":h", avrdudeFuseStr, TempFuseFilePath); p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.WorkingDirectory = SettingsManagement.AppDataPath; p.StartInfo.Arguments += String.Format(" -c {0} -p {1} -n {2} {3} {4}", owner.Project.BurnProgrammer, owner.Project.BurnPart, overrides, owner.Project.BurnOptions, action); try { File.Delete(TempFuseFilePath); } catch { } try { p.Start(); p.WaitForExit(5000); System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); while (true) { if (File.Exists(TempFuseFilePath)) { break; } if (sw.ElapsedMilliseconds > 5000) { break; } } if (File.Exists(TempFuseFilePath) == false) { MessageBox.Show("Failed to Read Fuse, temporary file not found at '" + TempFuseFilePath + "'. Here is the AVRDUDE output:" + Environment.NewLine + Environment.NewLine + p.StandardError.ReadToEnd() + Environment.NewLine + p.StandardOutput.ReadToEnd()); return(-1); } else { string fuseStr = File.ReadAllText(TempFuseFilePath); try { File.Delete(TempFuseFilePath); } catch { } if (string.IsNullOrEmpty(fuseStr)) { MessageBox.Show("Temporary Fuse File is Empty at " + TempFuseFilePath); return(-1); } fuseStr = fuseStr.Trim(); if (string.IsNullOrEmpty(fuseStr)) { MessageBox.Show("Temporary Fuse File is Empty at " + TempFuseFilePath); return(-1); } return(Convert.ToInt32(fuseStr, 16)); } } catch (Exception ex) { ErrorReportWindow.Show(ex, "Error While Reading Fuse"); } } return(-1); }