private void UploadFW(bool custom = false) { ArduinoSTK comPort = new ArduinoSTK(); uploader.Uploader uploader = new uploader.Uploader(); try { comPort.PortName = MainV2.comPort.BaseStream.PortName; comPort.BaudRate = 115200; comPort.Open(); } catch { CustomMessageBox.Show("Invalid ComPort or in use"); return; } bool bootloadermode = false; // attempt bootloader mode try { uploader_ProgressEvent(0); uploader_LogEvent("Trying Bootloader Mode"); uploader.port = comPort; uploader.connect_and_sync(); uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("In Bootloader Mode"); bootloadermode = true; } catch { // cleanup bootloader mode fail, and try firmware mode comPort.Close(); comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; try { comPort.Open(); } catch { CustomMessageBox.Show("Error opening port", "error"); return; } uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("Trying Firmware Mode"); bootloadermode = false; } // check for either already bootloadermode, or if we can do a ATI to ID the firmware if (bootloadermode || doConnect(comPort)) { uploader.IHex iHex = new uploader.IHex(); iHex.LogEvent += new LogEventHandler(iHex_LogEvent); iHex.ProgressEvent += new ProgressEventHandler(iHex_ProgressEvent); // put into bootloader mode/udpate mode if (!bootloadermode) { try { comPort.Write("AT&UPDATE\r\n"); string left = comPort.ReadExisting(); log.Info(left); Sleep(700); comPort.BaudRate = 115200; } catch { } } global::uploader.Uploader.Board device = global::uploader.Uploader.Board.FAILED; global::uploader.Uploader.Frequency freq = global::uploader.Uploader.Frequency.FAILED; // get the device type and frequency in the bootloader uploader.getDevice(ref device, ref freq); // get firmware for this device if (getFirmware(device, custom)) { // load the hex try { iHex.load(firmwarefile); } catch { CustomMessageBox.Show("Bad Firmware File"); goto exit; } // upload the hex and verify try { uploader.upload(comPort, iHex); } catch (Exception ex) { CustomMessageBox.Show("Upload Failed " + ex.Message); } } else { CustomMessageBox.Show("Failed to download new firmware"); } } else { CustomMessageBox.Show("Failed to identify Radio"); } exit: if (comPort.IsOpen) comPort.Close(); }
private void UploadFW(bool custom = false) { ICommsSerial comPort = new SerialPort(); uploader.Uploader uploader = new uploader.Uploader(); if (MainV2.comPort.BaseStream.IsOpen) { try { comPort = new MAVLinkSerialPort(MainV2.comPort, 0);//MAVLink.SERIAL_CONTROL_DEV.TELEM1); uploader.PROG_MULTI_MAX = 64; } catch (Exception ex) { CustomMessageBox.Show("Error " + ex.ToString()); } } try { comPort.PortName = MainV2.comPort.BaseStream.PortName; comPort.BaudRate = 115200; comPort.Open(); } catch { CustomMessageBox.Show("Invalid ComPort or in use"); return; } // prep what we are going to upload uploader.IHex iHex = new uploader.IHex(); iHex.LogEvent += new LogEventHandler(iHex_LogEvent); iHex.ProgressEvent += new ProgressEventHandler(iHex_ProgressEvent); bool bootloadermode = false; // attempt bootloader mode try { uploader_ProgressEvent(0); uploader_LogEvent("Trying Bootloader Mode"); uploader.port = comPort; uploader.connect_and_sync(); uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("In Bootloader Mode"); bootloadermode = true; } catch { // cleanup bootloader mode fail, and try firmware mode comPort.Close(); if (MainV2.comPort.BaseStream.IsOpen) { // default baud... guess comPort.BaudRate = 57600; } else { comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; } try { comPort.Open(); } catch { CustomMessageBox.Show("Error opening port", "Error"); return; } uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("Trying Firmware Mode"); bootloadermode = false; } // check for either already bootloadermode, or if we can do a ATI to ID the firmware if (bootloadermode || doConnect(comPort)) { // put into bootloader mode/udpate mode if (!bootloadermode) { try { comPort.Write("AT&UPDATE\r\n"); string left = comPort.ReadExisting(); log.Info(left); Sleep(700); comPort.BaudRate = 115200; } catch { } } // force sync after changing baudrate uploader.connect_and_sync(); global::uploader.Uploader.Board device = global::uploader.Uploader.Board.FAILED; global::uploader.Uploader.Frequency freq = global::uploader.Uploader.Frequency.FAILED; // get the device type and frequency in the bootloader uploader.getDevice(ref device, ref freq); // get firmware for this device if (getFirmware(device, custom)) { // load the hex try { iHex.load(firmwarefile); } catch { CustomMessageBox.Show("Bad Firmware File"); goto exit; } // upload the hex and verify try { uploader.upload(comPort, iHex); } catch (Exception ex) { CustomMessageBox.Show("Upload Failed " + ex.Message); } } else { CustomMessageBox.Show("Failed to download new firmware"); } } else { CustomMessageBox.Show("Failed to identify Radio"); } exit: if (comPort.IsOpen) comPort.Close(); }
private void BUT_upload_Click(object sender, EventArgs e) { ArduinoSTK comPort = new ArduinoSTK(); uploader.Uploader uploader = new uploader.Uploader(); try { comPort.PortName = MainV2.comPort.BaseStream.PortName; comPort.BaudRate = 115200; comPort.Open(); } catch { CustomMessageBox.Show("Invalid ComPort or in use"); return; } bool bootloadermode = false; try { uploader_ProgressEvent(0); uploader_LogEvent("Trying Bootloader Mode"); uploader.port = comPort; uploader.connect_and_sync(); uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("In Bootloader Mode"); bootloadermode = true; } catch { comPort.Close(); comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; comPort.Open(); uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("Trying Firmware Mode"); bootloadermode = false; } if (bootloadermode || doConnect(comPort)) { if (getFirmware()) { uploader.IHex iHex = new uploader.IHex(); iHex.LogEvent += new LogEventHandler(iHex_LogEvent); iHex.ProgressEvent += new ProgressEventHandler(iHex_ProgressEvent); try { iHex.load(firmwarefile); } catch { CustomMessageBox.Show("Bad Firmware File"); goto exit; } if (!bootloadermode) { try { comPort.Write("AT&UPDATE\r\n"); string left = comPort.ReadExisting(); Console.WriteLine(left); Sleep(700); comPort.BaudRate = 115200; } catch { } } try { uploader.upload(comPort, iHex); } catch (Exception ex) { CustomMessageBox.Show("Upload Failed " + ex.Message); } } else { CustomMessageBox.Show("Failed to download new firmware"); } } else { CustomMessageBox.Show("Failed to identify Radio"); } exit: if (comPort.IsOpen) comPort.Close(); }
private void UploadFW(bool custom = false) { ArduinoSTK comPort = new ArduinoSTK(); uploader.Uploader uploader = new uploader.Uploader(); try { comPort.PortName = MainV2.comPort.BaseStream.PortName; comPort.BaudRate = 115200; comPort.Open(); } catch { CustomMessageBox.Show("Invalid ComPort or in use"); return; } bool bootloadermode = false; // attempt bootloader mode try { uploader_ProgressEvent(0); uploader_LogEvent("Trying Bootloader Mode"); uploader.port = comPort; uploader.connect_and_sync(); uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("In Bootloader Mode"); bootloadermode = true; } catch { // cleanup bootloader mode fail, and try firmware mode comPort.Close(); comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; try { comPort.Open(); } catch { CustomMessageBox.Show("Error opening port", "error"); return; } uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("Trying Firmware Mode"); bootloadermode = false; } // check for either already bootloadermode, or if we can do a ATI to ID the firmware if (bootloadermode || doConnect(comPort)) { uploader.IHex iHex = new uploader.IHex(); iHex.LogEvent += new LogEventHandler(iHex_LogEvent); iHex.ProgressEvent += new ProgressEventHandler(iHex_ProgressEvent); // put into bootloader mode/udpate mode if (!bootloadermode) { try { comPort.Write("AT&UPDATE\r\n"); string left = comPort.ReadExisting(); log.Info(left); Sleep(700); comPort.BaudRate = 115200; } catch { } } global::uploader.Uploader.Board device = global::uploader.Uploader.Board.FAILED; global::uploader.Uploader.Frequency freq = global::uploader.Uploader.Frequency.FAILED; // get the device type and frequency in the bootloader uploader.getDevice(ref device, ref freq); // get firmware for this device if (getFirmware(device, custom)) { // load the hex try { iHex.load(firmwarefile); } catch { CustomMessageBox.Show("Bad Firmware File"); goto exit; } // upload the hex and verify try { uploader.upload(comPort, iHex); } catch (Exception ex) { CustomMessageBox.Show("Upload Failed " + ex.Message); } } else { CustomMessageBox.Show("Failed to download new firmware"); } } else { CustomMessageBox.Show("Failed to identify Radio"); } exit: if (comPort.IsOpen) { comPort.Close(); } }
private void UploadFW(bool custom = false) { ICommsSerial comPort = new SerialPort(); uploader.Uploader uploader = new uploader.Uploader(); if (MainV2.comPort.BaseStream.IsOpen) { try { comPort = new MAVLinkSerialPort(MainV2.comPort, 0);//MAVLink.SERIAL_CONTROL_DEV.TELEM1); uploader.PROG_MULTI_MAX = 64; } catch (Exception ex) { CustomMessageBox.Show("Error " + ex.ToString()); } } try { comPort.PortName = MainV2.comPort.BaseStream.PortName; comPort.BaudRate = 115200; comPort.Open(); } catch { CustomMessageBox.Show("Invalid ComPort or in use"); return; } // prep what we are going to upload uploader.IHex iHex = new uploader.IHex(); iHex.LogEvent += new LogEventHandler(iHex_LogEvent); iHex.ProgressEvent += new ProgressEventHandler(iHex_ProgressEvent); bool bootloadermode = false; // attempt bootloader mode try { uploader_ProgressEvent(0); uploader_LogEvent("Trying Bootloader Mode"); uploader.port = comPort; uploader.connect_and_sync(); uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("In Bootloader Mode"); bootloadermode = true; } catch { // cleanup bootloader mode fail, and try firmware mode comPort.Close(); if (MainV2.comPort.BaseStream.IsOpen) { int fixme_guessbaud; // default baud... guess comPort.BaudRate = 57600; } else { comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; } try { comPort.Open(); } catch { CustomMessageBox.Show("Error opening port", "error"); return; } uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); uploader_LogEvent("Trying Firmware Mode"); bootloadermode = false; } // check for either already bootloadermode, or if we can do a ATI to ID the firmware if (bootloadermode || doConnect(comPort)) { // put into bootloader mode/udpate mode if (!bootloadermode) { try { comPort.Write("AT&UPDATE\r\n"); string left = comPort.ReadExisting(); log.Info(left); Sleep(700); comPort.BaudRate = 115200; } catch { } } // force sync after changing baudrate uploader.connect_and_sync(); global::uploader.Uploader.Board device = global::uploader.Uploader.Board.FAILED; global::uploader.Uploader.Frequency freq = global::uploader.Uploader.Frequency.FAILED; // get the device type and frequency in the bootloader uploader.getDevice(ref device, ref freq); // get firmware for this device if (getFirmware(device, custom)) { // load the hex try { iHex.load(firmwarefile); } catch { CustomMessageBox.Show("Bad Firmware File"); goto exit; } // upload the hex and verify try { uploader.upload(comPort, iHex); } catch (Exception ex) { CustomMessageBox.Show("Upload Failed " + ex.Message); } } else { CustomMessageBox.Show("Failed to download new firmware"); } } else { CustomMessageBox.Show("Failed to identify Radio"); } exit: if (comPort.IsOpen) { comPort.Close(); } }
private void BUT_upload_Click(object sender, EventArgs e) { ArduinoSTK comPort = new ArduinoSTK(); uploader.Uploader uploader = new uploader.Uploader(); try { comPort.PortName = MainV2.comPort.BaseStream.PortName; comPort.BaudRate = 115200; comPort.Open(); } catch { CustomMessageBox.Show("Invalid ComPort or in use"); return; } bool bootloadermode = false; uploader.ProgressEvent += new ProgressEventHandler(uploader_ProgressEvent); uploader.LogEvent += new LogEventHandler(uploader_LogEvent); try { uploader_ProgressEvent(0); uploader_LogEvent("Trying Bootloader Mode"); uploader.port = comPort; uploader.connect_and_sync(); uploader_LogEvent("In Bootloader Mode"); bootloadermode = true; } catch { comPort.Close(); comPort.BaudRate = MainV2.comPort.BaseStream.BaudRate; comPort.Open(); uploader_LogEvent("Trying Firmware Mode"); bootloadermode = false; } if (bootloadermode || doConnect(comPort)) { if (getFirmware()) { uploader.IHex iHex = new uploader.IHex(); iHex.LogEvent += new LogEventHandler(iHex_LogEvent); iHex.ProgressEvent += new ProgressEventHandler(iHex_ProgressEvent); try { iHex.load(firmwarefile); } catch { CustomMessageBox.Show("Bad Firmware File"); goto exit; } if (!bootloadermode) { try { comPort.Write("AT&UPDATE\r\n"); string left = comPort.ReadExisting(); Console.WriteLine(left); Sleep(700); comPort.BaudRate = 115200; } catch { } } try { uploader.upload(comPort, iHex); } catch (Exception ex) { CustomMessageBox.Show("Upload Failed " + ex.Message); } } else { CustomMessageBox.Show("Failed to download new firmware"); } } else { CustomMessageBox.Show("Failed to identify Radio"); } exit: if (comPort.IsOpen) { comPort.Close(); } }