public static void EnterBslMode(string port) { if (port == string.Empty) { throw new ArgumentException("port empty"); } AdapterProtocol ap = null; try { ap = new AdapterProtocol(port); ap.Open(); ap.Clear(); ap.EnterBslMode(); } catch (Exception) { throw; } finally { try { if (ap != null) { ap.Close(); } } catch (System.IO.IOException ex) { Logger.Warn("could not close serial port: {0}", ex.Message); } } }
public static void EnterBslMode(BaseDevice device) { if (device.TwiKfdtoolDevice.ComPort == string.Empty) { throw new ArgumentException("No device selected"); } AdapterProtocol ap = null; try { ap = new AdapterProtocol(device.TwiKfdtoolDevice.ComPort); ap.Open(); ap.Clear(); ap.EnterBslMode(); } catch (Exception) { throw; } finally { try { if (ap != null) { ap.Close(); } } catch (System.IO.IOException ex) { Logger.Warn("could not close serial port: {0}", ex.Message); } } }