private void Flash(string Port, string ArduinoFile, int ArduinoID) { bool AllDone = false; try { var options = new ArduinoSketchUploaderOptions { PortName = Port, FileName = Application.StartupPath + @"\lib\ArduinoHex\AmiiBombuino." + ArduinoFile + ".hex", ArduinoModel = (ArduinoModel)ArduinoID }; var uploader = new ArduinoSketchUploader(options); uploader.UploadSketch(); AllDone = true; } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (AllDone) { MessageBox.Show(i18n.__("AmiiBombuino_All_Done"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Invoke(new Action(() => this.Close())); } } }
private void upload_Click(object sender, EventArgs e) { this.uploadProgressBar.Visible = true; var progress = new Progress <double>( p => UpdateProgress(p)); var options = new ArduinoSketchUploaderOptions() { FileName = Path.Combine(AppContext.BaseDirectory, "Fino.ino.hex"), PortName = this.arduinoPortName, ArduinoModel = ArduinoModel.Micro }; var uploader = new ArduinoSketchUploader( options, new FormArduinoUploaderLogger(logger), progress); var thread = new Thread(() => { try { uploader.UploadSketch(); logger.Info("Uploaded to Arduino. Please click on 'Detect Ports' just in case the Arduino device has changed ports"); } catch (Exception ex) { logger.Error(ex, ex.Message); } }); thread.Start(); }
static void Main(string[] args) { System.IO.Ports.SerialPort ProMicroUSBSerial = new System.IO.Ports.SerialPort("COM5", 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One); String HexFilePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); String HexFileNameWithFullPath = HexFilePath + "\\Rov5ArdumotoPacketSerial.hex"; Console.WriteLine($"Load {HexFileNameWithFullPath} to {ProMicroUSBSerial.PortName}"); Console.WriteLine("Reset Pro Micro then press any key..."); Console.ReadKey(); //ProMicroUSBSerial.Open(); var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = HexFileNameWithFullPath, PortName = ProMicroUSBSerial.PortName, ArduinoModel = ArduinoUploader.Hardware.ArduinoModel.Leonardo }); try { uploader.UploadSketch(); string successString = string.Format(format: "Successfully Pro Micro firmware from file: {0}", arg0: HexFileNameWithFullPath); Console.WriteLine(successString); } catch (Exception ex) { string errorString = "Programming FAILED: cycle power to Pro Micro device and try again\n\n" + ex.Message; Console.WriteLine(errorString); } Console.WriteLine("Press any key to quit..."); Console.ReadKey(); }
private static void ExecuteAutoBootStrap(ArduinoModel arduinoModel, string portName) { logger.Info("Executing AutoBootStrap!"); logger.Info("Deploying protocol version {0}.{1}.", CurrentProtocolMajorVersion, CurrentProtocolMinorVersion); logger.Debug("Reading internal resource stream with Arduino Listener HEX file..."); var assembly = Assembly.GetExecutingAssembly(); var textStream = assembly.GetManifestResourceStream( string.Format(ArduinoListenerHexResourceFileName, arduinoModel)); if (textStream == null) { throw new IOException("Unable to configure auto bootstrap, embedded resource missing!"); } var hexFileContents = new List <string>(); using (var reader = new StreamReader(textStream)) while (reader.Peek() >= 0) { hexFileContents.Add(reader.ReadLine()); } logger.Debug("Uploading HEX file..."); var uploader = new ArduinoSketchUploader(new ArduinoSketchUploaderOptions { PortName = portName, ArduinoModel = arduinoModel }); uploader.UploadSketch(hexFileContents); }
private void button4_Click(object sender, EventArgs e) { try { timer2.Stop(); timer3.Stop(); serialPort1.Close(); checkBox_random.CheckState = CheckState.Unchecked; trackBar_red.Value = 0; trackBar_green.Value = 0; trackBar_blue.Value = 0; string connect = Convert.ToString(comboBox1.SelectedItem); string path = System.IO.Directory.GetCurrentDirectory(); string pathino = path + "\\" + "LEDRGB.ino.hex"; var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = pathino, PortName = connect, ArduinoModel = ArduinoModel.UnoR3 }); uploader.UploadSketch(); //MessageBox.Show("Upload Done!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void button1_Click(object sender, EventArgs e) { // Open TV remote page and send TV app to arduino /*TO DO: * * Get path of program package and find arduino files from there * * Make drop down with port names or identify the one with an arduino on it. * */ //mySerP.Write("H"); Cursor.Current = Cursors.AppStarting; //string[] ports = SerialPort.GetPortNames(); //use to make dropdown var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = Globals.arduinoPath + Globals.remoteCode, PortName = Globals.sPortName, ArduinoModel = ArduinoUploader.Hardware.ArduinoModel.UnoR3 }); uploader.UploadSketch(); Cursor.Current = Cursors.Default; Form2 remote = new Form2(); remote.ShowDialog(); }
void Upload_Schetch() { if (MySerial != null) //Make sure MySerial port is closed { if (MySerial.IsOpen) //if open, close { MySerial.Close(); Task.Delay(2000).Wait(); MySerial = null; } } //if (MySerial.IsOpen) { MySerial.Close(); } string tipo = ""; if (TipoBox.Text == "1D - 500x500") { tipo = @"calib1D.ino.eightanaloginputs.hex"; } else if (TipoBox.Text == "3D - 500x500") { tipo = @"calib3D.ino.eightanaloginputs.hex"; } else if (TipoBox.Text == "6D - 400x600") { tipo = @"calib3D.ino.eightanaloginputs.hex"; } else if (TipoBox.Text == "") { tipo = @"calib1D.ino.eightanaloginputs.hex"; TipoBox.SelectedIndex = 0; } try { if (SerialPortsBox.Text == "") { SerialPortsBox.Items.Clear(); SerialPortsBox.Items.AddRange(SerialPort.GetPortNames()); SerialPortsBox.SelectedIndex = 0; } var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = tipo, PortName = SerialPortsBox.Text, ArduinoModel = ArduinoModel.NanoR3 }); uploader.UploadSketch(); UpdateCalibLog("Placa configurada para plataforma " + TipoBox.Text); } catch (Exception ex) { MySerial.Close(); MessageBox.Show("Erro: " + ex.Message); } }
private void ExecuteAutoBootStrap(ArduinoModel arduinoModel) { logger.Info("Executing AutoBootStrap!"); logger.Info("Deploying protocol version {0}.{1}.", CurrentProtocolMajorVersion, CurrentProtocolMinorVersion); var portName = port.PortName; logger.Debug("Closing port {0}...", portName); port.Close(); logger.Debug("Reading internal resource stream with Arduino Listener HEX file..."); var assembly = Assembly.GetExecutingAssembly(); var textStream = assembly.GetManifestResourceStream( string.Format(ArduinoListenerHexResourceFileName, arduinoModel)); if (textStream == null) { throw new IOException("Unable to configure auto bootstrap, embedded resource missing!"); } var hexFileContents = new List <string>(); using (var reader = new StreamReader(textStream)) while (reader.Peek() >= 0) { hexFileContents.Add(reader.ReadLine()); } logger.Debug("Uploading HEX file..."); var uploader = new ArduinoSketchUploader(new ArduinoSketchUploaderOptions { PortName = portName, ArduinoModel = arduinoModel }); uploader.UploadSketch(hexFileContents); logger.Debug("Reopening port {0}...", portName); port.Open(); // Now wait a bit, the Arduino might still be restarting! Thread.Sleep(GraceTimeAfterArduinoAutoBootStrap); // After bootstrapping, check if we can succesfully handshake ... var response = port.Send(new HandShakeRequest()); var handshakeResponse = response as HandShakeResponse; if (handshakeResponse == null) { throw new IOException("Unable to get a handshake ACK after executing auto bootstrap on the Arduino!"); } logger.Info("Arduino (auto)bootstrapped succesfully!"); }
public void upload() { var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = @"C:\MyHexFiles\UnoHexFile.ino.hex", PortName = "COM3", ArduinoModel = ArduinoModel.UnoR3 } ); uploader.UploadSketch(); }
public void uploadSketch(string Filename, ArduinoModel model, string port, int baudrate) { _uploaderClass = new uploaderClass(Filename, port, model); ArduinoSketchUploader uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = Filename, PortName = port, ArduinoModel = model }); uploader.UploadSketch(); }
public void uploadCheckSketch(string port, ArduinoModel model, int baudrate) { string filePath = "checkSktech.ino.eightanaloginputs.hex"; ArduinoSketchUploader uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = filePath, PortName = port, ArduinoModel = model }); uploader.UploadSketch(); }
private void Wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { ArduinoSketchUploader uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = fileName, PortName = comPortText, ArduinoModel = model }); this.Dispatcher.BeginInvoke(new Action(() => arduinoBinaryDownloaderWindow.statusTextBlock.Text = "Uploading the Binary to the Arduino")); //try to close open COM-ports foreach (LedItem item in LedItem.AllItems) { if (item.ComPortName == comPortText) { item.CloseSerial(); } } //upload the binary try { uploader.UploadSketch(); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { new AlertWindow("Failed to upload binary!", false).ShowDialog(); MainWindow.ActiveWindow.logBoxText.Text += $"Failed to upload binary to model { modelText } at { comPortText } ({ ex.GetType().Name })"; MainWindow.ActiveWindow.logBoxText.Text += Environment.NewLine; })); return; } this.Dispatcher.BeginInvoke(new Action(() => { arduinoBinaryDownloaderWindow.Close(); new AlertWindow("Finished uploading", false).ShowDialog(); MainWindow.ActiveWindow.ShowArduinoUploadWindow = false; //remove the eventhandler from the uploadArduinoBinaryBackgroundGrid MainWindow.ActiveWindow.uploadArduinoBinaryBackgroundGrid.MouseUp -= CancelBtn_Click; })); }
void UploadCodeToArduino(Loading loading) { try { string filePath = null; if (arduino1.Model == ArduinoModel.NanoR2 || arduino1.Model == ArduinoModel.NanoR3) { filePath = "/Microcontroller/led_nano_v1.0.ino.hex"; } else if (arduino1.Model == ArduinoModel.UnoR3) { filePath = "/Microcontroller/led_uno_v1.0.ino.hex"; } else if (arduino1.Model == ArduinoModel.Mega2560) { filePath = "/Microcontroller/led_mega2560_v1.0.ino.hex"; } else if (arduino1.Model == ArduinoModel.Leonardo) { filePath = "/Microcontroller/led_leonardo_v1.0.ino.hex"; } else if (arduino1.Model == ArduinoModel.Micro) { filePath = "/Microcontroller/led_micro_v1.0.ino.hex"; } ArduinoSketchUploader uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions { FileName = String.Concat(Directory.GetCurrentDirectory(), filePath), PortName = arduino1.Port, ArduinoModel = arduino1.Model } ); this.Enabled = false; Port.Close(); uploader.UploadSketch(); Task.Delay(1000).Wait(); Port.Open(); } catch (Exception e) { MessageBox.Show("Upload Failed", "Error"); } this.Enabled = true; metroTabControl1.Controls.Find("Arduino", true).FirstOrDefault().Controls.Remove(loading); loading.Dispose(); GC.Collect(); }
static void Main(string[] args) { Eclock eclock = new Eclock(); string serialPort = eclock.GetPort(); string[] ports = SerialPort.GetPortNames(); string commPort = ""; Console.WriteLine("Start Uploading Eclock Program."); foreach (var item in ports) { if (serialPort.Contains(item)) { commPort = item; } } string userName = Environment.UserName; string path = AppDomain.CurrentDomain.BaseDirectory; string programFileName = path + "Eclock.ino.mega.hex"; if (File.Exists(programFileName) && commPort != "") { Console.WriteLine("Program Uploading..."); var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = programFileName, PortName = commPort, ArduinoModel = ArduinoModel.Mega2560 }); uploader.UploadSketch(); Console.WriteLine("Program Uploading Completed..."); } else { if (commPort == "") { Console.WriteLine("Check E-Clock connection."); } else { Console.WriteLine("Program File Missing."); } } }
public void writeProgram(string port) { if (!ValidConnection) { var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = @"..\..\..\..\Cajon\Cajon.ino.hex", PortName = port, ArduinoModel = ArduinoModel.NanoR3 }); uploader.UploadSketch(); } else { throw new InvalidOperationException("Nejprve se odpojte"); } }
private void BWDoWork(object sender, DoWorkEventArgs e) { var asuo = new ArduinoSketchUploaderOptions(); asuo.FileName = SelectedFile; asuo.PortName = SelectedPort; asuo.ArduinoModel = ArduinoUploader.Hardware.ArduinoModel.Leonardo; var logger = new SketchUploaderLogReceiver(); var progress = new Progress <double>( p => logger.Info($"Programming progress: {p * 100:F1}% ...")); progress.ProgressChanged += (isender, ie) => UploadProgressChanged(isender, ie); var uploader = new ArduinoSketchUploader(asuo, logger, progress); uploader.UploadSketch(); }
private void burnCodeOne_Click(object sender, EventArgs e) { try { if (_ComPort != null && _ComPort.IsOpen) { MessageBox.Show("Please disconnect first from arduino."); return; } if (string.IsNullOrEmpty(textBoxFilePath.Text) || string.IsNullOrWhiteSpace(SelectedPortName)) { MessageBox.Show("Please Select File Path."); return; } if (SelectedArduinoModel == null) { MessageBox.Show("Please Select an Arduino Model."); return; } if (string.IsNullOrEmpty(SelectedPortName) || string.IsNullOrWhiteSpace(SelectedPortName)) { MessageBox.Show("Please Select a Port Name."); return; } var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = @"" + textBoxFilePath.Text, PortName = SelectedPortName, ArduinoModel = SelectedArduinoModel.Value }); uploader.UploadSketch(); MessageBox.Show("Code Upload Completed."); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btn_upload_Click(object sender, EventArgs e) { ArduinoSketchUploaderOptions options = new ArduinoSketchUploaderOptions(); //options.ArduinoModel = ArduinoUploader.Hardware.ArduinoModel.UnoR3; options.ArduinoModel = ArduinoUploader.Hardware.ArduinoModel.NanoR3; options.FileName = this.lbl_file.Text; PortDesc selectedPort = (PortDesc)this.cmb_ports.SelectedItem; options.PortName = selectedPort.DeviceId; ArduinoSketchUploader uploader = new ArduinoSketchUploader(options, null, null); this.lbl_msg.Text = "Uploading ..."; uploader.UploadSketch(); this.lbl_msg.Text = "Upload Completed."; }
private void button8_Click(object sender, EventArgs e) { try { string connect = Convert.ToString(comboBox1.SelectedItem); string path = System.IO.Directory.GetCurrentDirectory(); string pathino = path + "\\" + "LEDRGB.ino.hex"; var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = pathino, PortName = connect, ArduinoModel = ArduinoModel.UnoR3 }); uploader.UploadSketch(); MessageBox.Show("Upload Done!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void Run_Uploader(string serialPortName, string FilePath) { // Upload HEX Uno file var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = FilePath, PortName = serialPortName, ArduinoModel = ArduinoModel.UnoR3 } ); try { uploader.UploadSketch(); } catch { MessageBox.Show("Error! Please try erasing current program on Arduino", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void UploadSketch() { ArduinoProgress progress = new ArduinoProgress(UpdateProgress); ArduinoModel?model = SketchVersion.ArduinoTypeToModel(_latestVersion.Type); if (model == null) { _logging.Error(MODUL_NAME, "UploadSketch", $"invalid arduino type {_latestVersion.Type}"); return; } var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = _latestVersion.Filename, PortName = _comPortName, ArduinoModel = model.Value, }, new ArduinoLogger(), progress ); /* * string hexStr = Helper.GetEmbeddedTextRessource(LatestSketchName); * if (string.IsNullOrEmpty(hexStr)) * { * _logging.Error(MODUL_NAME, "UploadSketch", $"Error reading embedded resource '{LatestSketchName}'"); * return; * } * string[] hexLines = hexStr.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); */ Helper.ControlInvokeRequired(StatusLbl, () => { StatusLbl.Text = "Uploading Sketch"; }); Helper.ControlInvokeRequired(UploadPb, () => { UploadPb.Minimum = 0; UploadPb.Maximum = 100; UploadPb.Step = 1; UploadPb.Value = 0; }); try { //uploader.UploadSketch(hexLines); uploader.UploadSketch(); } catch (Exception ex) { _logging.Error(MODUL_NAME, "UploadSketch", $"UploadSketch error ex={ex}"); Helper.ControlInvokeRequired(StatusLbl, () => { StatusLbl.Text = "Sketch upload error"; }); return; } UpdateProgress(1.0); Helper.ControlInvokeRequired(StatusLbl, () => { StatusLbl.Text = "Sketch upload completed"; }); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { try { string HexFile = ""; UploadStatus = UploadResult.Failed; if (UserSelectedFile) { HexFile = tbHexfile.Text; } else { if (ckRtEthernet.Checked && ckRtOldBootloader.Checked) { // ethernet, old bootloader HexFile = Path.GetTempFileName(); File.WriteAllBytes(HexFile, PCBsetup.Properties.Resources.RateOB_ino); } else if (ckRtEthernet.Checked && !ckRtOldBootloader.Checked) { // ethernet, new bootloader HexFile = Path.GetTempFileName(); File.WriteAllBytes(HexFile, PCBsetup.Properties.Resources.Rate_ino); } else if (!ckRtEthernet.Checked && !ckRtOldBootloader.Checked) { // no ethernet, new bootloader HexFile = Path.GetTempFileName(); File.WriteAllBytes(HexFile, PCBsetup.Properties.Resources.RateNE_ino); } else if (!ckRtEthernet.Checked && ckRtOldBootloader.Checked) { // no ethernet, old bootloader HexFile = Path.GetTempFileName(); File.WriteAllBytes(HexFile, PCBsetup.Properties.Resources.RateOBNE_ino); } } if (File.Exists(HexFile)) { timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_elapsed); timer.Start(); ArduinoModel Model; if (ckRtOldBootloader.Checked) { Model = ArduinoModel.NanoR3; } else { // work-around for new bootloader // https://github.com/twinearthsoftware/ArduinoSketchUploader/issues/32 Model = ArduinoModel.UnoR3; } var uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = @HexFile, PortName = mf.PortName, ArduinoModel = Model }); uploader.UploadSketch(); timer.Stop(); UploadStatus = UploadResult.Completed; } } catch (Exception ex) { if (ex.Message.Contains("sync")) { UploadStatus = UploadResult.Sync_Error; } timer.Stop(); } }
private void CompileSketch() { Status = "Changing MotorShield options"; Progress = 5; string[] config = File.ReadAllLines($@".\{SelectedConfig.Name}\{SelectedConfig.ConfigFile}"); Progress = 10; if (SelectedConfig.Name == "BaseStationClassic") { config[16] = $"#define MOTOR_SHIELD_TYPE {(int)SelectedMotorShield.ShieldType}"; } else if (SelectedConfig.Name == "BaseStationEX") { config[17] = $"#define MOTOR_SHIELD_TYPE {(int)SelectedMotorShield.ShieldType}"; } Progress = 15; File.WriteAllLines($@".\{SelectedConfig.Name}\{SelectedConfig.ConfigFile}", config); Progress = 20; Thread.Sleep(1000); Status = $"Compiling {SelectedConfig.DisplayName} Sketch"; if (!Directory.Exists($@".\{SelectedConfig.Name}\Build")) { Directory.CreateDirectory($@".\{SelectedConfig.Name}\Build"); } if (!Directory.Exists($@".\{SelectedConfig.Name}\Cache")) { Directory.CreateDirectory($@".\{SelectedConfig.Name}\Cache"); } Progress = 25; ProcessStartInfo start = new ProcessStartInfo(); start.FileName = $@".\arduino-1.8.12\arduino-1.8.12\arduino-builder.exe"; start.Arguments = String.Format($@"{SelectedConfig.InitCommand}", SelectedBoard.FQBN); start.UseShellExecute = true; start.WindowStyle = ProcessWindowStyle.Hidden; Process process = new Process(); process.StartInfo = start; process.Start(); process.WaitForExit(); Progress = 50; start.Arguments = String.Format($@"{SelectedConfig.BuildCommand}", SelectedBoard.FQBN); Console.WriteLine(start.Arguments); process.Start(); process.WaitForExit(); Status = $"Compilation Complete"; RefreshingPorts = true; Thread.Sleep(1000); Status = $"Uploading to {SelectedComPort}"; Progress = 75; if (File.Exists(@"./upload.log")) { File.Delete(@"./upload.log"); } ArduinoSketchUploader uploader = new ArduinoSketchUploader( new ArduinoSketchUploaderOptions() { FileName = $@"{Directory.GetCurrentDirectory()}\{SelectedConfig.Name}\Build\{SelectedConfig.OutputFileName}.ino.hex", PortName = SelectedComPort, ArduinoModel = SelectedBoard.Platform }, this); try { uploader.UploadSketch(); Status = "Upload Completed Successfully. Please check upload.log for more details"; } catch (Exception e) { Status = "Upload Failed!!! Please check upload.log for more details"; File.AppendAllText(@"./upload.log", $"Message: {e.Message} {Environment.NewLine} StackTrace: {e.StackTrace}"); } Progress = 100; Thread.Sleep(1000); Progress = 0; Busy = false; RefreshingPorts = false; }