public AvrDudeWindow(AVRProject project) { InitializeComponent(); // two projects allow changes to be discarded this.originalProject = project; this.project = project.Clone(); burnerPanel = new BurnerPanel(this.project); grpboxBurnerPanel.Controls.Add(burnerPanel); burnerPanel.Dock = DockStyle.Fill; burnerPanel.ProjToForm(); dropDetectionType.SelectedIndex = 0; dropMemoryType.SelectedIndex = 0; // this is the only way i can think of that will // allow the user to view the progress bar live // by using the command line window // because redirecting STDERR doesn't work since // the .NET built-in stream redirection only has // the ability to read line by line so the progress // bar is lost ProjectBuilder.SetEnviroVarsForProc(avrdude.StartInfo); avrdude.StartInfo.FileName = "cmd"; }
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 string GetOverrides() { string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, project); return(overrides); }
public FuseCalculator(AVRProject project) { InitializeComponent(); this.originalProject = project; this.project = project.Clone(); burnerPanel = new BurnerPanel(this.project); tabAVRDUDE.Controls.Add(burnerPanel); this.Text = "Fuse Calculator for " + project.Device.ToUpperInvariant(); txtYourFusebox.Text = project.BurnFuseBox; }
public static string GetArgs(AVRProject project) { string overrides = ""; BurnerPanel.GetPortOverride(ref overrides, project); string res = String.Format("-p {0} -c {1} {2} {3}", project.BurnPart.ToUpperInvariant(), project.BurnProgrammer, overrides, project.BurnOptions); while (res.Contains(" ")) { res = res.Replace(" ", " "); } return(res); }
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); }
public ConfigWindow(AVRProject project) { InitializeComponent(); if (orderedDevices == null) { orderedDevices = new List <string>(); } if (orderedDevices.Count == 0) { foreach (string s in dropDevices.Items) { if (orderedDevices.Contains(s.ToLowerInvariant()) == false) { orderedDevices.Add(s.ToLowerInvariant()); } } string pathToXmls = SettingsManagement.AppInstallPath + "chip_xml" + Path.DirectorySeparatorChar; if (Directory.Exists(pathToXmls)) { foreach (FileInfo fi in new DirectoryInfo(pathToXmls).GetFiles()) { if (fi.Name.ToLowerInvariant() != "interruptvectors.xml") { if (fi.Name.ToLowerInvariant().EndsWith(".xml")) { string name = Path.GetFileNameWithoutExtension(fi.Name).ToLowerInvariant().Trim(); if (orderedDevices.Contains(name) == false) { orderedDevices.Add(name); } } } } } orderedDevices.Sort((x, y) => string.Compare(x, y)); } dropDevices.Items.Clear(); foreach (string s in orderedDevices) { dropDevices.Items.Add(s); } this.originalProject = project; this.project = project.Clone(); burnerPanel = new BurnerPanel(this.project); grpBoxBurnerPanel.Controls.Add(burnerPanel); burnerPanel.Dock = DockStyle.Fill; this.originalProject.HasBeenConfigged = true; this.project.HasBeenConfigged = true; string[] templateList = ProjTemplate.GetTemplateNames(); foreach (string tempName in templateList) { dropTemplates.Items.Add(tempName); } if (dropTemplates.Items.Count == 0) { dropTemplates.Items.Add("No Templates Available"); } dropTemplates.SelectedIndex = 0; PopulateForm(); }
public ConfigWindow(AVRProject project) { InitializeComponent(); if (orderedDevices == null) orderedDevices = new List<string>(); if (orderedDevices.Count == 0) { foreach (string s in dropDevices.Items) { if (orderedDevices.Contains(s.ToLowerInvariant()) == false) { orderedDevices.Add(s.ToLowerInvariant()); } } string pathToXmls = SettingsManagement.AppInstallPath + "chip_xml" + Path.DirectorySeparatorChar; if (Directory.Exists(pathToXmls)) { foreach (FileInfo fi in new DirectoryInfo(pathToXmls).GetFiles()) { if (fi.Name.ToLowerInvariant() != "interruptvectors.xml") { if (fi.Name.ToLowerInvariant().EndsWith(".xml")) { string name = Path.GetFileNameWithoutExtension(fi.Name).ToLowerInvariant().Trim(); if (orderedDevices.Contains(name) == false) orderedDevices.Add(name); } } } } orderedDevices.Sort((x, y) => string.Compare(x, y)); } dropDevices.Items.Clear(); foreach (string s in orderedDevices) dropDevices.Items.Add(s); this.originalProject = project; this.project = project.Clone(); burnerPanel = new BurnerPanel(this.project); grpBoxBurnerPanel.Controls.Add(burnerPanel); burnerPanel.Dock = DockStyle.Fill; this.originalProject.HasBeenConfigged = true; this.project.HasBeenConfigged = true; string[] templateList = ProjTemplate.GetTemplateNames(); foreach (string tempName in templateList) { dropTemplates.Items.Add(tempName); } if (dropTemplates.Items.Count == 0) { dropTemplates.Items.Add("No Templates Available"); } dropTemplates.SelectedIndex = 0; PopulateForm(); }
private void SetButtonText() { btnBurnOnlyOpt.Text = String.Format(BUTTON_TEXT, BurnerPanel.GetArgs(this.project)); }
private string GetArgs() { return(BurnerPanel.GetArgs(this.project)); }